Inorder Traversal of Binary Tree
You are provided with a binary tree consisting of 'N' nodes, where each node carries an integer value. Your task is to determine the in-order traversal of the given binary tree.
Example:
Input:
For the given binary tree:
1 3 8 5 2 7 -1 -1 -1 -1 -1 -1 -1
Output:
The Inorder traversal will be [5, 3, 2, 1, 7, 4, 6].
Explanation:
The input represents the level order traversal of the binary tree. Each level is denoted consecutively, and a '-1' symbolizes a null node. For example:
[
Level 1: 1
Level 2: 3 8
Level 3: 5 2 7 -1
]
Constraints:
1 <= T <= 10
0 <= N <= 3000
0 <= data <= 10^9
- Time limit: 1 second
Input:
The first line contains an integer 'T' which denotes the number of test cases.
The first line of each test case contains elements of the tree in level order. Values of nodes are separated by a single space, with -1 representing a null node.
Output:
For each test case, return a vector containing the in-order traversal as space-separated integers.
Note:
- No need to print the output, focus on implementing the function to return results.
- The input terminates when all elements at the lowest level are null (-1).

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, and f...read more
Venky
4mo
works at
Hgvhj
Single person can have a maximum of nine active slam Varada registered under their Aadhaar card for daily use
Help your peers!
Add answer anonymously...
Jio Software Developer interview questions & answers
A Software Developer was asked 2mo agoQ. Given a singly linked list, reverse the list and return the reversed list.
A Software Developer was asked 4mo agoQ. Count the occurrences of each element, and if the count is equal to a specified ...read more
A Software Developer was asked 7mo agoQ. What are abstraction and interfaces in Java?
Popular interview questions of Software Developer
A Software Developer was asked 2mo agoQ1. Given a singly linked list, reverse the list and return the reversed list.
A Software Developer was asked 4mo agoQ2. Count the occurrences of each element, and if the count is equal to a specified ...read more
A Software Developer was asked 7mo agoQ3. What are abstraction and interfaces in Java?
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

