In other words, If you were to read the values of the leaves in a red black tree from left-to-right immediately after an insertion, would that order remain the same after performing balancing operations on the tree?
Asked
Active
Viewed 39 times
0
-
1Perhaps I don't understand your question correctly, but due to a red-black tree being sorted shouldn't the order from left to right always be the same? Otherwise it wouldn't be sorted anymore. – Wolph May 05 '15 at 00:48
-
What @Wolph said. Rebalancing operations in binary search trees must preserve the leaf order, otherwise the tree would lose correctness. – Rafał Dowgird May 05 '15 at 07:42
1 Answers
1
Re-balancing may make a sibling of a node its new parent, but it can not change the relative order. Keep in mind that the red-black tree is a binary search tree and thus it should keep elements smaller than a given element in its left subtree and elements greater than it in its right subtree. Swapping the children of a vertex will reverse the inequality.

Ivaylo Strandjev
- 69,226
- 18
- 123
- 176