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!
Select
Add answer anonymously...

Springworks Software Developer Intern interview questions & answers

A Software Developer Intern was asked Q. Linear Probing in Hashing Hashing is a technique to map large non-negative integ...read more
A Software Developer Intern was asked Q. Roman Numeral to Integer Conversion Convert a string representing a Roman numera...read more
A Software Developer Intern was asked Q. Pair Sum Problem Statement You are given an array of integers 'ARR' with a lengt...read more

Popular interview questions of Software Developer Intern

A Software Developer Intern was asked Q1. Linear Probing in Hashing Hashing is a technique to map large non-negative integ...read more
A Software Developer Intern was asked Q2. Roman Numeral to Integer Conversion Convert a string representing a Roman numera...read more
A Software Developer Intern was asked Q3. Pair Sum Problem Statement You are given an array of integers 'ARR' with a lengt...read more
Springworks Software Developer Intern Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
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

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits