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.
AnswerBot
1y
The task is to find the in-order traversal of a given binary tree.
Implement a recursive function to perform in-order traversal of the binary tree
Start from the left subtree, then visit the root node, ...read more
Help your peers!
Add answer anonymously...
Top Springworks Software Developer Intern interview questions & answers
Popular interview questions of Software Developer Intern
Top HR questions asked in Springworks Software Developer Intern
>
Springworks Software Developer Intern Interview Questions
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app