While the remaining root has a left child, apply a right tree rotation there. Once the left child is null, output the root and advance to its right child. The output already produced followed by the remaining inorder sequence is invariant. There are exactly output removals and rotations, because rotations decrease the left-size potential and removals preserve it. The algorithm therefore takes linear time and constant auxiliary pointer space, at the cost of changing the input links.
Articles by others on the same topic
There are currently no matching articles.