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

后端 未结 10 1281
广开言路
广开言路 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:41

    I think there's no way you could do this, as you should somehow find the nodes where you left off in a path and to identify that you always need O(height) space.

提交回复
热议问题