@vikas :
you can use recursive approach to draw tree here we go:
6 4 3 5 7 8 11 12
1 ) 6 is root since 4 < 6 , 4 is left child of 6
2) find value which is more than 6 , so it is 7 in this case... hence 7 is
right child.
3 ) Hence we break this list in three part; 1. Root node (6) 2. left sub
tree (4,3,5) 3. right subtree (7,8,11,12)
6
/ \
(4,3,5) (7,8,11,12)
we repeat same 3 steps for left and right sub tree.
So we need only one Preorder traversal.
On Mon, Aug 29, 2011 at 1:22 AM, vikas <[email protected]> wrote:
> @ Sagar, level order can be stored but you need to remember the nulls
> always
>
> On Aug 29, 12:06 am, sagar pareek <[email protected]> wrote:
> > level order traversal is best for this case :)
> >
> > On Sun, Aug 28, 2011 at 11:53 PM, prashant thorat
> > <[email protected]>wrote:
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > > only preorder will suffice.. considering fact that it's BST
> >
> > > On Sun, Aug 28, 2011 at 11:26 PM, Rishabbh A Dua <[email protected]
> >wrote:
> >
> > >> Please correct me if i am wrong but isnt the answer to this q is AVL
> > >> trees????
> >
> > >> On Sun, Aug 28, 2011 at 10:43 PM, Dhriti Khanna <[email protected]
> >wrote:
> >
> > >>> @ Navneet: See if the tree is: 6
> > >>> 4 7
> > >>> 3 5 8
> >
> > >>> Then the preorder traversal is : 6 4 3 5 7 8
> > >>> And using this preorder traversal and inserting them in the tree one
> by
> > >>> one, we generate this exact tree.
> >
> > >>> --
> > >>> You received this message because you are subscribed to the Google
> Groups
> > >>> "Algorithm Geeks" group.
> > >>> To post to this group, send email to [email protected].
> > >>> To unsubscribe from this group, send email to
> > >>> [email protected].
> > >>> For more options, visit this group at
> > >>>http://groups.google.com/group/algogeeks?hl=en.
> >
> > >> --
> > >> Rishabbh A Dua
> >
> > >> --
> > >> You received this message because you are subscribed to the Google
> Groups
> > >> "Algorithm Geeks" group.
> > >> To post to this group, send email to [email protected].
> > >> To unsubscribe from this group, send email to
> > >> [email protected].
> > >> For more options, visit this group at
> > >>http://groups.google.com/group/algogeeks?hl=en.
> >
> > > --
> > > Yours affectionately,
> > > Prashant Thorat
> > > Computer Science and Engg. Dept,
> > > NIT Durgapur.
> >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups
> > > "Algorithm Geeks" group.
> > > To post to this group, send email to [email protected].
> > > To unsubscribe from this group, send email to
> > > [email protected].
> > > For more options, visit this group at
> > >http://groups.google.com/group/algogeeks?hl=en.
> >
> > --
> > **Regards
> > SAGAR PAREEK
> > COMPUTER SCIENCE AND ENGINEERING
> > NIT ALLAHABAD
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>
--
Yours affectionately,
Prashant Thorat
Computer Science and Engg. Dept,
NIT Durgapur.
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.