@ashish
i forgot recussion uses memory but if we have to do it without using
stack also then
pickup the root and add it to the bst and to fill the vacant position
of root choose left node and make it root and to adjust previous right
node at it to leaf
eg :

                  D
               /     \
              A      E
            /     \
          B      C
add D to the BST and add E to the leaf
                  A
               /     \
              B     C
            /
          E
adding E to the leaf node can be done memory without using extra memory.



On Wed, Apr 28, 2010 at 8:22 PM, Ashish Mishra <[email protected]> wrote:
> @rajesh can u explain your soln
> how u r doing inorder, pre or whatever (without using stack) and at same
> time build BST
>
> On Wed, Apr 28, 2010 at 3:30 PM, Rajesh Patidar <[email protected]>
> wrote:
>>
>> pickup node in any order no matter(pre,post,inorder)  and just one by
>> one. start adding the node into bst no need to use extra space u have
>> to just ditach the node from binary tree and attach it in bst.
>>
>> On Wed, Apr 28, 2010 at 1:18 AM, Ashish Mishra <[email protected]>
>> wrote:
>> > How to build BST from binary tree in place i.e without extra space ??
>> >
>> > --
>> > 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.
>> >
>>
>>
>>
>> --
>> ~~~~BL/\CK_D!AMOND~~~~~~~~
>>
>> --
>> 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.
>>
>
>
>
> --
> Ashish Mishra
> http://ashishmishra.weebly.com/
>
> --
> 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.
>



-- 
~~~~BL/\CK_D!AMOND~~~~~~~~

-- 
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.

Reply via email to