Just store the parent on every node. On Mon, Sep 6, 2010 at 11:08 PM, Debajyoti Sarma <[email protected]> wrote: > How to print the path from root to a specific node in a binary tree?? > I want to store the path in a array[] of node*. > can it b done in O(n) or less? > Remember it's not BST. > > 1 > / \ > 2 3 > / \ / \ > 4 5 6 7 > / \ / \ / \ / \ > 8 9 10 11 12 13 14 15 > > path of 6 will b 1,3,6. > path of 9 will be 1,2,5,11 > > -- > 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. > >
-- 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.
