Inorder Traversal (Recursive)

Learning Traversals DSA practice problem on Onlearn.

Difficulty: easy.

Topics: Recursive Inorder Traversal of a Binary Tree, Binary Tree, In-order Traversal, Recursion, inorder traversal, space complexity, dfs, binary tree, call stack, recursion base case, recursion, time complexity analysis, tree traversal.

Problem Statement Given the root of a binary tree, return the inorder traversal of its nodes' values. In an inorder traversal, the nodes are recursively visited in the following order: 1. Traverse the left subtree. 2. Visit the root node. 3. Traverse the right subtree. You must implement the solution using a recursive approach. Input Specification The input consists of a list of integers representing the binary tree in level order traversal (standard serialization format). null or N indicates an empty node. Output Specification Return (or print) a list of space separated integers representing the inorder traversal of the given tree. Constraints The number of nodes in the tree is in the range [0, 100]. 100 <= Node.val <= 100 Sample Test Cases Sample Input 1 Tree Structure: Sample Output 1 Explanation: Traverse left subtree of 1 (Node 2). Traverse left subtree of 2 (Node 4) Visit 4. Visit Root (2). Traverse right subtree of 2 (Node 5) Visit 5. Visit Root (1). Traverse right subtree of 1 (Node 3) Visit 3. Sample Input 2 Tree Structure: Sample Output 2 Explanation: Traverse left subtree of 1 (Empty). Visit Root (1). Traverse right subtree of 1 (Node 2). Traverse left subtree of 2 (Node 3) Visit 3. Visit Root (2). Sample Input 3 Sample Output 3 Difficulty Level Easy