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
Determine the class invariants- Ruby Ruby has many predefined exceptions classes (like ArgumentError) and new ones can be created easily by sub-classing StandardError, so it's

State the range of operation of ADT Operations of the Range of T ADT includes following, where a, b ∈ T and r and s are values of Range of T: a...b-returns a range value (an

Illustrates the program for Binary Search. Program: Binary Search /*Header Files*/ #include #include /*Functions*/ void binary_search(int array[ ], int value,

Arrays are simple, however reliable to employ in more condition than you can count. Arrays are utilized in those problems while the number of items to be solved out is fixed. They

Operation of Algorithm The following sequence of diagrams shows the operation of Dijkstra's Algorithm. The bold vertices show the vertex to which shortest path has been find ou

AVL trees are applied into the given situations: There are few insertion & deletion operations Short search time is required Input data is sorted or nearly sorted

Consistent Heuristic Function - Graph Search Recall the notions of consistency and admissibility for an A* search heuristic. a. Consider a graph with four nodes S, A, B, C,

GIVE TRACE OF BINARY SEARCH ALGORITHM BY USING A SUITABLE EXAMPLE.

Explain Internal and External Nodes  To  draw  the  tree's  extension  by  changing  the  empty  subtrees  by  special nodes. The  extra  nodes shown by little squares are know

write an algorithm to find the average number of occurances of MECHANIL in an english passage