![](https://static.ambitionbox.com/alpha/community/assets/dots.png)
Sorted Order Printing of a BST Array
Given a Binary Tree consisting of 'N' nodes with integer values, your task is to determine the in-order traversal of the Binary Tree.
Input:
The first line contains an integer 'T', indicating the number of test cases.
Each test case consists of a single line containing the elements of the tree in level order. The line includes values of nodes separated by a single space. If a node is null, it is denoted by -1.
Output:
For each test case, output a vector containing the In-Order traversal values of the given Binary Tree. Each test case's output should be a line of 'N' space-separated integers representing the node values in In-Order traversal.
Example:
Input:
2
1 3 8 5 2 7 -1 -1 -1 -1 -1 -1 -1
10 4 6 -1 -1 5 8
Output:
[5, 3, 2, 1, 7, 4, 6]
[4, 10, 5, 6, 8]
Explanation:
Example 1 depicts the tree where Node 1 is the root. The traversal follows In-Order (Left, Root, Right), resulting in [5, 3, 2, 1, 7, 4, 6].
Constraints:
1 <= T <= 10
0 <= N <= 3000
0 <= data <= 10^9
(where 'data' denotes the node value of the binary tree nodes)
Note:
You don't need to print anything, it has already been taken care of. Implement the function provided.
![](https://static.ambitionbox.com/alpha/community/assets/no-posts.png)
Be the first one to answer
Add answer anonymously...
Top Visa Software Engineer interview questions & answers
Popular interview questions of Software Engineer
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