InterviewSolution
| 1. |
Write A Program To Convert A Binary Tree Into A Doubly Linked List? |
|
Answer» This problem is opposite of question 25 where you need to write a program to CONVERT a double linked LIST to the balanced BINARY tree. The left and right pointers in NODES of a binary tree will be USED as previous and next pointers respectively in converted doubly linked list. The order of nodes in the doubly linked list must be same as Inorder of the given Binary Tree. The first node of Inorder traversal (left most node in the binary tree) must be the head node of the doubly linked list. This problem is opposite of question 25 where you need to write a program to convert a double linked list to the balanced binary tree. The left and right pointers in nodes of a binary tree will be used as previous and next pointers respectively in converted doubly linked list. The order of nodes in the doubly linked list must be same as Inorder of the given Binary Tree. The first node of Inorder traversal (left most node in the binary tree) must be the head node of the doubly linked list. |
|