Inorder Traversal of Binary Tree
You are provided with a Binary Tree composed of 'N' nodes, each holding integer values. Your task is to compute the Inorder traversal of this binary tree.
Example:
For the given binary tree, the Inorder traversal will be: [5, 3, 2, 1, 7, 4, 6].
Input:
The first line contains an integer 'T' indicating the number of test cases. Each test case consists of a single line representing the binary tree in level order format. Node values are space-separated, and -1 indicates a null node.
Output:
For each test case, output a single line containing the Inorder traversal of the binary tree, with node values separated by spaces.
Example:
Input:
1
1 3 8 5 2 7 -1 -1 -1 -1 -1 -1 -1
Output:
5 3 2 1 7 8
Constraints:
- 1 <= T <= 10
- 0 <= N <= 3000
- 0 <= data <= 10^9
- Time limit: 1 sec
Note:
You are not required to print anything; just implement the provided function to complete the task.
Be the first one to answer
Add answer anonymously...
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

