First of all, isn’t treap a self-balancing tree? If so, why isn’t there any rotation operations in it?
https://s3.amazonaws.com/codechef_shared/download/Solutions/LTIME25/Tester/CHEFDTRE.cpp
But in another implementations, I saw the use of rotation
Which one is better for competitive programming?
Also, I have a doubt in the following code
void split (pitem t, int key, pitem & l, pitem & r) {
if (! t)
l = r = NULL;
else if (key <t-> key)
split (t-> l, key, l, t-> l), r = t;
else
split (t-> r, key, t-> r, r), l = t;
}
Shouldn’t the split be
split (t-> l, key, l, r-> l), r = t;
split (t-> r, key, l-> r, r), l = t;
Also, is the assignment (r=t and l=t) taking place before split or after it?