I personally dont think so.
2008/2/11 Pradeep Muthukrishnan <[EMAIL PROTECTED]>:
> Is it even possible to do taht in constant space?
>
> 2008/2/11 [EMAIL PROTECTED] <[EMAIL PROTECTED]>:
>
>
> > Thanks for all the effort. Sorry, I should have mentioned it earlier.
> > But, we are asked to do it without modifying the tree in any manner
> > and using no more than a constant space outside the tree.
> >
> >
> >
> >
> > On Feb 11, 8:17 am, "phani bandaru" <[EMAIL PROTECTED]> wrote:
> > > Use inorder traversal without recursion.
> > >
> > > On 2/11/08, James Fang <[EMAIL PROTECTED]> wrote:
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > > Use a queue, assume the root of the binary tree : pRoot;
> > > > Below is the pseudo code:
> > >
> > > > enQueue(pRoot);
> > > > While( queue not empty )
> > > > {
> > > > pNode = outQueue();
> > > > print(pNode);
> > > > if(pNode->left)
> > > > {
> > > > enQueue(pNode->left);
> > > > }
> > > > if(pNode->right)
> > > > {
> > > > enQueue(pNode->right);
> > > > }
> > > > }
> > >
> > > > -----邮件原件-----
> > > > 发件人: [email protected] [mailto:[EMAIL PROTECTED]
> > 代表
> > > > [EMAIL PROTECTED]
> > > > 发送时间: 2008年2月11日 8:13
> > > > 收件人: Algorithm Geeks
> > > > 主题: [algogeeks] a non-recursive algorithm that prints all the nodes
> > of a
> > > > binary tree in O(n)
> > >
> > > > This is an exercise problem in the book "Introduction to Algorithms"
> > > > by CLR. Could any one come up with an algorithm to do it.
> > >
> > > --
> > > pUrNamadah pUrNamidam
> > > pUrNAt pUrNamudachyate
> > > pUrNasya pUrNamAdAya
> > > pUrNamevAvashiShyate- Hide quoted text -
> > >
> > > - Show quoted text -
> > > >
> >
--
Ciao,
Ajinkya
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---