Inorder and preorder traversal to reconstruct a binary tree, Data Structure & Algorithms

Q. Using the following given inorder and preorder traversal reconstruct a binary tree

Inorder sequence is

D, G, B, H, E, A, F, I, C


Preorder sequence is

A, B, D, G, E, H, C, F, I

 

Ans:

The In-order sequence given to us is :- D, G, B, H, E, A, F, I, C

Pre-order sequence given to us is:- A, B, D, G, E, H, C, F, I

The binary tree T is drawn from its root downward by selecting the first node in its pre-order as root of T then study the left and right child recursively. The tree T is drawn below:

 

 

1354_Binary Tree.png

Posted Date: 7/10/2012 7:14:43 AM | Location : United States







Related Discussions:- Inorder and preorder traversal to reconstruct a binary tree, Assignment Help, Ask Question on Inorder and preorder traversal to reconstruct a binary tree, Get Answer, Expert's Help, Inorder and preorder traversal to reconstruct a binary tree Discussions

Write discussion on Inorder and preorder traversal to reconstruct a binary tree
Your posts are moderated
Related Questions
One can change a binary tree into its mirror image by traversing it in Postorder is the only proecess whcih can convert binary tree into its mirror image.


A full binary tree with n leaves have:- 2n -1 nodes.

(1)  (i) Add the special form let to the metacircular interpreter Hint: remember let is just syntactic sugar for a lambda expression and so a rewrite to the lambda form is all t

Your objective is to write a generic doubly linked list class called CS228LinkedList that implements the List interface and uses a type variable T. All methods except for subList a

What are the Objectives of visual realism applications After studying this unit, you should be able to know specific needs of realism, add realism to pictures by el

What is the difference between a grounded header link list and a circular header link list? A header linked list is a linked list which always having a special node, known as t

Spanning Trees: A spanning tree of a graph, G, refer to a set of |V|-1 edges which connect all vertices of the graph. There are different representations of a graph. They are f

In computer programming, Trees are utilized enormously. These can be utilized for developing database search times (binary search trees, AVL trees, 2-3 trees, red-black trees), Gam