Binary Search Tree To Doubly Linked List
Convert Binary search tree to doubly linked list.
Note: BiNode – is a data structure that has two pointers to two nodes. It used to represent both data structure, a binary tree or doubly linked list.
Algorithm:
- Recursively go to left end
- Recursively go to right end
- If left child exists then
- Get to tail of left child
- Merge after root node after tail
- If Right child exists then
- Merge right child before root
- If left child exists then
- return left child
- Else
- return root
Latest Source Code:
Github: BinarySearchTreeToDoublyLinkedList.java
Output:
Tree InOrder: 8, 14, 20, 25, 40, 50, 100, DLL from head side: 8, 14, 20, 25, 40, 50, 100, DLL from Tail side: 100, 50, 40, 25, 20, 14, 8,