I am having some difficulties splaying the element 4 to the root. Considering the following splay tree.
0
\
1
\
2
\
3
\
4
Could anyone show me the steps how to get the 4 to the root?
Computer Science Stack Exchange is a question and answer site for students, researchers and practitioners of computer science. It only takes a minute to sign up.
Sign up to join this communityI am having some difficulties splaying the element 4 to the root. Considering the following splay tree.
0
\
1
\
2
\
3
\
4
Could anyone show me the steps how to get the 4 to the root?
Just follow the algorithm. First you have to do a zag-zag-rotation, which gives you
0
\
1
\
4
/
3
/
2
Then you have to do another zag-zag-rotation and you obtain as the result of splay(4) the tree
4
/
1
/ \
0 3
/
2