Created
July 18, 2018 17:54
-
-
Save amberovsky/105013acf8d6574a409289283d9b7880 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Tii(Ins[p1, c1], Ins[p2, c2]) { | |
if (p1 < p2) || ((p1 == p2) && (order() == -1)) // order() – order calculation | |
return Ins[p1, c1]; // Tii(Ins[3, ‘a’], Ins[4, ‘b’]) = Ins[3, ‘a’] | |
else | |
return Ins[p1 + 1, c1]; // Tii(Ins[3, ‘a’], Ins[1, ‘b’]) = Ins[4, ‘a’] | |
} | |
Tid(Ins[p1, c1], Del[p2]) { | |
if (p1 <= p2) | |
return Ins[p1, c1]; // Tid(Ins[3, ‘a’], Del[4]) = Ins[3, ‘a’] | |
else | |
return Ins[p1 – 1, c1]; // Tid(Ins[3, ‘a’], Del[1]) = Ins[2, ‘a’] | |
} | |
Tdi(Del[p1], Ins[p2, c1]) { | |
// Exercise | |
} | |
Tdd(Del[p1], Del[p2]) { | |
if (p1 < p2) | |
return Del[p1]; // Tdd(Del[3], Del[4]) = Del[3] | |
else | |
if (p1 > p2) return Del[p1 – 1]; // Tdd(Del[3], Del[1]) = Del[2] | |
else | |
return Id; // Id – identity operator | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment