Iterating over a Binary Tree with O(1) Auxiliary Space

后端 未结 10 1258
广开言路
广开言路 2020-11-30 04:03

Is it possible to iterate over a binary tree in O(1) auxiliary space (w/o using a stack, queue, etc.), or has this been proven impossible? If it is possible, how can it be

10条回答
  •  执笔经年
    2020-11-30 04:44

    http://en.wikipedia.org/wiki/XOR_linked_list

    encode your parent node into the leaf pointers

提交回复
热议问题