Finding max depth of binary tree without recursion

前端 未结 7 943
夕颜
夕颜 2020-12-24 09:23

Recursive mechanism to find max depth of depth of binary tree is very straightforward, but how can we do it efficiently without recursion as I have large tree where I would

7条回答
  •  眼角桃花
    2020-12-24 09:42

    If you can maintain left and right values at each node, it can be done.

    http://leetcode.com/2010/04/maximum-height-of-binary-tree.html.

    Possible duplicate: Retrieving a Binary-Tree node's depth non-recursively

提交回复
热议问题