Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

If you invert the tree such that each node points to its parent, and there are no child pointers, you lose information. Namely, the order among children is lost. A given interior node still has two children as before, but it is not known which is the left child and which is the right child; there is just a set of up to two nodes which point to the same parent.

The binary tree inverse specifications/implementations I have looked at preserve the information by selectively using the left or right links. For instance, given:

     P
    / \ 
   L   R
The inverse would be:

   L   R
    \ /
     P
Both children point to the parent. But the left child uses its right pointer, and the right child uses the left pointer. That's what preserves the information about which child is which.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: