• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is it possible to generate Binary Tree from the expression given in Inorder?

 
Rohit Aggarawal
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As per me, it is not possible. Can any one share thoughts on it?
 
Geoff Jefferson
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can't help but wonder if this is a homework problem.
If it is, then I really don't think this forum is the right
place to do your research.

 
Steve Fahlbusch
Bartender
Posts: 605
7
Mac OS X Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well why would it be impossible?

in order is just a traversal pattern for a tree, so doing the opposite, ie: generating a tree from a traversal pattern would not seem un do able
 
Rohit Aggarawal
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
one Intern guy has recently joined my company in Bangalore and asked me this Question.

As per my understanding, it is not possible to do it.

I just want to validate my understanding.
 
Jim Hoglund
Ranch Hand
Posts: 525
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One view of an in-order traversal would be that its output is an ordered list. To find
or place an element in it, you would interrupt the scan when the proper location is
found. With a b-tree however, searches and inserts become a series of left-or-right
decisions where each decision eliminates the need for many compares. So these
ideas of looking at everything in order (traversal), versus finding the right slot
(b-tree search), don't have a lot in common.

Jim ... ...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic