94 Binary Tree Inorder Traversal
94. Binary Tree Inorder Traversal
1. Question
Given a binary tree, return the inorder traversal of its nodes' values.
For example:
Given binary tree[1,null,2,3]
,
return[1,3,2]
.
Note: Recursive solution is trivial, could you do it iteratively?
2. Implementation
(1) Morris Tree Traversal
(2) Iteration
3. Time & Space Complexity
(1) Morris Tree Traversal: 时间复杂度: O(n), 空间复杂度: O(1)
(2) Iteration: 时间复杂度: O(n), 空间复杂度:O(h)
Last updated
Was this helpful?