ExamAdda Logo

Binary Tree Inorder Traversal

Easy

Description

Given the root of a binary tree, return its inorder traversal of the node values.

Inorder traversal visits the nodes in this order:

Left → Root → Right

Example 1

Input

3
1 2 3

Output

2 1 3

Explanation

The binary tree is:

     1

    / \

  2    3

 

Inorder traversal:

Left → Root → Right 2 → 1 → 3

 

Example 2

Input

5
1 2 3 4 5

Output

4 2 5 1 3

Explanation

The tree is:     

   1   

  / \  

  2   3  

 / \  

4   5

 

Therefore, the inorder traversal is:

4 → 2 → 5 → 1 → 3

Constraints

0 <= number of nodes <= 100
-100 <= Node.val <= 100

Hints:

Hint 1

In inorder traversal, always process the left subtree first, then the current node, and finally the right subtree.

Hint 2

You can solve this recursively by calling inorder traversal on the left and right children.

Author & Technical Reviewer

ExamAdda Technical Review Team

Technically reviewed by: ExamAdda Technical Review Team

Technical Reviewers, ExamAdda

Software engineers at ExamAdda who check every article's definitions, complexity claims and code examples before and after publishing.

Published

Aug 10, 2026

Last updated

Aug 10, 2026

Content Verification Methodology

Definitions and complexity claims were checked against authoritative computer-science references. Code examples were compiled and tested with standard, boundary and edge-case inputs.

Report a correction:editorial@examadda.org
Auto
Loading editor...
Input

Expected Output