CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2012

    Re creating a Binary Tree


    Can we re create a Binary Tree Given

    1. Any one of the Traversals PreOrder,InOrder, PostOrder? I think no.
    2. Any two them? I think Inorder With Pre/Post Order then Yes.
    Pre and Post Order(Without Inorder) I think No.

    Is this correct ?

  2. #2
    Join Date
    Apr 2012

    Re: Re creating a Binary Tree

    Answers For re creating a Binary Tree only when the traversals are given

    1. Given Only One of the Traversal We cant build a tree
    2. Given Inorder + PreOrder/PostOrder Yes we can build a binary tree
    3. Given Pre + Post Order we cant build a Tree. Because if there is a single node in a tree we cant Decide where the node should fall Left Or Right. As
    In PreOrder Root Left Right and in PostOrder Left Right Root. Now if there is a single node then we cant tell whether it falls on Left Or Right based on traversal data alone. But in case of Inorder it is Left Root Right; Now if there is a single Node then we can identify wether it falls on left or right by looking at Traversal data.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)