Java program to convert a given binary tree to doubly linked list
In this program, we need to convert the given binary tree to corresponding doubly liked list.
The binary tree is a tree data structure in which each node has at most two children node.
This can be achieved by traversing the tree in the in-order manner that is, left the child -> root ->right node. Traverse left sub-tree and convert it into the doubly linked list by adding nodes to the end of the list. In this way, leftmost node will become head of the list. Then, convert the right sub-tree into the doubly linked list.
a. display() will show all the nodes present in the list.
Nodes of generated doubly linked list: 4 2 5 1 6 3 7