798 views
2 2 votes
Given a tree of 3 nodes A,B and C, the Inorder Traversal is CAB and the Preorder Traversal is ABC. What is the structure of the tree?

1 Answer

Best answer
3 3 votes
You do damage to property of preorder and inorder

preoder : Root Left Right

Inorder : Left Root Right

you gave

CAB as inorder means A is root then C is left and then B is right

So how in preorder how can  B be a left child.

So here you are take preorder of one tree and inorder of another tree. Hope u got it
• selected by
Position:
Show:

Related questions

0 0 votes
1 1 answer
675
675 views
Samujjal Das asked Dec 2, 2016
675 views
Suppose we are given a set of elements to be inserted in a Max Heap. What is the approach to follow from the following?1.Insert an element, apply HEAPIFY, insert the next...
1 1 vote
2 answers 2 answers
1.2k
1.2k views
Jithin Jayan asked Jul 23, 2016
1,176 views
Given an unsorted Array of n elements and asked to find the Largest element of that array. Can we use Max-Heapify Procedure to find the Largest element in that array in O...
0 0 votes
3 3 answers
1.2k
1.2k views
Jithin Jayan asked Jul 13, 2016
1,157 views
Given only pre-order of a Binary Search Tree, Can we identify a Binary Search Tree Uniquely?