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

Assignment Help:

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


Related Discussions:- Inorder and preorder traversal to reconstruct a binary tree

Train reorganising, A freight train from Melbourne is approaching Sydney, c...

A freight train from Melbourne is approaching Sydney, carrying n cars of cargos. The cargos are to be delivered to n different cities in the metropolitan area of Sydney - one car f

Stack, implement multiple stacks ina single dimensional array. write algori...

implement multiple stacks ina single dimensional array. write algorithams for various stack operation for them.

Data structures, Aa) Come up with an ERD from the following scenario, clear...

Aa) Come up with an ERD from the following scenario, clearly stating all entities, attributes, relationships before final sketch of the ERD: [50 m

The space - time trade off, The Space - Time Trade Off The best algorit...

The Space - Time Trade Off The best algorithm to solve a given problem is one that needs less space in memory and takes less time to complete its implementation. But in practic

Data Structure, Ask consider the file name cars.text each line in the file ...

Ask consider the file name cars.text each line in the file contains information about a car ( year,company,manufacture,model name,type) 1-read the file 2-add each car which is repr

Explain about hidden-surface, Explain about Hidden-surface Hidden-line...

Explain about Hidden-surface Hidden-line removal refers to wire-frame diagrams without surface rendering and polygonal surfaces with straight edges. Hidden-surface removal ref

What is binary search, What is binary search?   Binary search is most ...

What is binary search?   Binary search is most useful when list is sorted. In binary search, element present in middle of the list is determined. If key (the number to search)

Determine yiq colour model, Determine YIQ Colour Model Whereas an RGB m...

Determine YIQ Colour Model Whereas an RGB monitor requires separate signals for the red, green, and blue components of an image, a television monitor uses a single composite si

Binary search, In a sorted list, Binary search is carried out by dividing t...

In a sorted list, Binary search is carried out by dividing the list into two parts depends on the comparison of the key. Since the search interval halves each time, the iteration o

Functions and modelling the data flows, Read the scenario (Pickerings Prope...

Read the scenario (Pickerings Properties). (a) List the functions of the system, as perceived by an external user. (b) List the external entities. Note that because we are mo

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd