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
In this project you will write a program to produce a discrete time simulation of a queue as shown in Fig. 1. Time is slotted on the input and the output. Each input packet follows

1.Create a flowchart to show the process that will allow the implementation of Stack, Push, and Pop operations. 2.Create a flowchart to show the process that will allow the impleme

the voltage wave forms are applied at the inputs of an EX-OR gate. determine the output wave form

Q. Describe the term array.  How do we represent two-dimensional arrays in memory?  Explain how we calculate the address of an element in a two dimensional array.

1.  You are required to hand in both a hard copy and an electronic copy of the written report on the project described in A, including all the diagrams you have drawn.  2.  You

Depth-first traversal A depth-first traversal of a tree visit a node and then recursively visits the subtrees of that node. Likewise, depth-first traversal of a graph visits

Determine the effect of Ruby in implementation of string Ruby has a String class whose instances are mutable sequences of Unicode characters. Symbol class instances are charact

Description A heap is an efficient tree-based data structure that can be used as a priority queue. Recall that the abstract data type of a priority queue has the following opera

Define File organization''s and it''s types

A binary search tree (BST), which may sometimes also be named a sorted or ordered binary tree, is an edge based binary tree data structure which has the following functionalities: