BST To DLL
Last updated
Last updated
Convert a binary search tree to a sorted doubly linked list in place.
Node definition? node.left is prev and node.right is next.
In order traversal will print the nodes in a sorted order. Linking up the final node and the first node then it will be circular. In place is the hard part because we need to modify the tree structure.
Iterative in-order traversal is one approach. The treenode is saved in stack so modifying will not lose the link.