AlgoViz

Inorder Traversal

Inorder traversal visits nodes in Left-Root-Right order. For BST, this gives sorted output.

BeginnerTime: O(n)Space: O(h)
Take Quiz
503070204060801025354555657590
Step 1 / 0

Current Step

Click Play to start the visualization


## How Inorder Traversal Works

Inorder traversal visits nodes in the order: Left subtree -> Root -> Right subtree. For Binary Search Trees, this produces nodes in sorted (ascending) order.

### Algorithm Steps:
1. Recursively traverse the left subtree
2. Visit the current node (process/print it)
3. Recursively traverse the right subtree

### Key Characteristics:
- **Sorted output for BST**: Visits nodes in ascending order
- **Stack-based**: Uses call stack or explicit stack
- **O(n) time**: Visits each node exactly once

Time & Space Complexity

CaseTime Complexity
BestO(n)
AverageO(n)
WorstO(n)
SpaceO(h)

Practice Problems

No Problems Available

Practice problems for this algorithm are coming soon!