bugfree Icon
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course

Leetcode Problem 94. Binary Tree Inorder Traversal

94. Binary Tree Inorder Traversal

Leetcode Solutions

Iterative Inorder Traversal Using Stack

  1. Initialize an empty stack.
  2. Initialize a pointer to the root node.
  3. While the stack is not empty or the pointer is not null: a. If the pointer is not null, push it onto the stack and move to its left child. b. If the pointer is null, pop a node from the stack, add its value to the result list, and move to its right child.
  4. Return the result list containing the inorder traversal.
UML Thumbnail

Recursive Inorder Traversal

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...
bugfree Icon
OR