when doing left and right rotation of a binary search tree: Do I have to preserve all in, post and pre-order or just one order ?
In order of a BST should always yield output in sorted order so it must be preserved.
Pre-order and post order can change depending upon the rotations
as we can see in the case of
X
Y
Z
We have after rotation say
Y
Z X
Then we can see the pre-order in the earlier case was XYZ and in the second case the preorder becomes YZX so it is not same
postorder is ZYX but in second case it is ZXY so it can also change but inorder is always
ZYX in both cases
Do give a thumbs up
Get Answers For Free
Most questions answered within 1 hours.