believe my tree looks like this
5
/ \
3 7
/ \ / \
2 4 6 8
in that, when searching for an element 2, the zigzig operation is performed in time, so first we rotate parent and ancestor of 2, then rotate a parent and 2.
in the same case, consider what we are looking for 4, that the zigzag time operation will be performed. first we rotate 4 and its parent, then it 4 and its ancestorwill be rotated.
why we did it, in a zigzag, why we don’t rotate parent and ancestorinstead searching node and parent.
Please explain me?? Thanks in advance.
source
share