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); > } > } > > > > -----邮件原件----- > 发件人: algogeeks@googlegroups.com [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 --~--~---------~--~----~------------~-------~--~----~ 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 to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/algogeeks -~----------~----~----~----~------~----~------~--~---