I agree, this seems like freshman algo homework, ask TA for a hint.
The algorithm I described previously works fine. and it's probly in
one of the books anyways... U need something like a Potential
function, and do some monkeying around with it and it all works out.
On Feb 11, 10:04 pm, Sunny <[
Pls , you should not discuss your homework assignments on this group. :
(
On Feb 11, 5:12 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> This is an exercise problem in the book "Introduction to Algorithms"
> by CLR. Could any one come up with an algorithm to do it.
--~--~-~--~~-
keep track of the last node you visited...
if you are coming from the left child, go to the right child...
if you are coming from the right child, go to the parent...
thats the brief idea...
--~--~-~--~~~---~--~~
You received this message because you are subscribed
assume parent pointers...then you can
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this group, send email
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 wi
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
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 rec
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)
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);
}
}