1. Python 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, the leftmost node will become head of the list. Then, convert the right sub-tree into the doubly linked list. ALGORITHM:
a. display() will show all the nodes present in the list.
PROGRAM:Output: Nodes of generated doubly linked list: 4 2 5 1 6 3 7 Next TopicPython Programs |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India