**Construct a binary tree using the following
pre - order and in - order trasversals :
Pre-order:ABGHMCDEF
In-order:BHMGADFEC **

I Just Need a Diagram of Binary Tree . I have tried a lot with youtube tutorials but not getting the answer plz help.

Recommended Answers

This may help.

Jump to Post

All 2 Replies

Member Avatar

I think the traversals may be incorrect. The Fact that A is first in pre order suggests it is the root node, B being second is either left of it or the first on the right where there is not left.
However The Fact that B is first on the In-order says that B is actually either root or the left most node and a child of H These two sets of conditions are mutually exclusive!

This may help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.