FastPrepInorder Traversal Without Recursion
Problems/Inorder Traversal Without Recursion

Inorder Traversal Without Recursion

Adobe logoAdobe● EasyINTERNPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: This problem lists the values of a binary tree in in-order, with a follow-up to do it without recursion. In the report, that follow-up came after a recursive version. The iterative one ran long for the author, and the interviewer then went on to other questions. The report is a post (published July 2022) about a one-hour technical interview held on 10 December 2021 for Adobe's 2022 Product Intern role, reached through Adobe's SheCodes campus program. Puzzles came before this item. The report gives no input format, limits or examples, and no final result.

Our choices: the answer is the list of values. There are 1 to 2000 nodes, with values from -10^4 to 10^4, so a tree can be 2000 levels deep. The examples are new. We check only the output, so we do not check whether a solution avoids recursion. The editorial teaches the iterative version.

Our version is about 85% the same as the reported question.

Given the root of a binary tree, return its node values in in-order: first the left subtree in in-order, then the node itself, then the right subtree in in-order.

Follow-up: solve it without recursion. The judge checks only the returned list, not how it was built; note that a tree here can be up to 2000 levels deep.

Function

inorderValues(root: TreeNode) → List<Integer>

Examples

Example 1

root = [5,8,1,null,3,6]return = [8,3,5,6,1]
root
58316

The left subtree of 5 is 8 with a right child 3, which gives 8, 3. Then comes 5 itself. The right subtree is 1 with a left child 6, which gives 6, 1. In-order: [8, 3, 5, 6, 1].

Example 2

root = [-2,7,null,4,null,0]return = [0,4,7,-2]
root
-2740

Every node has only a left child, so the walk goes all the way down first: 0, then 4, 7 and finally the root -2.

Example 3

root = [11]return = [11]
root
11

A single node: [11].

Constraints

  • The tree has 1 to 2000 nodes.
  • -10^4 <= Node.val <= 10^4

More Adobe Phone Screen questions

  • Evaluate a Parenthesized Integer ExpressionPHONE SCREEN · Seen Oct 2026
  • All Elements of Two BSTs in OrderPHONE SCREEN · Seen Aug 2026
  • Rotate an Array In PlaceOA · PHONE SCREEN · Seen Aug 2026
  • Binary Tree Level-Order Traversal by LevelsPHONE SCREEN · ONSITE INTERVIEW · Seen Aug 2026
  • Count Occurrences in a Sorted ArrayPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2026
  • Count Pairs with Absolute Difference KPHONE SCREEN · Seen Jul 2026
  • Count Subsets with Sum KPHONE SCREEN · Seen Jul 2026
  • Numbers with Exactly Three DivisorsPHONE SCREEN · Seen Jul 2026
  • Sum of Even Nodes on a Path in a Numbered Binary TreePHONE SCREEN · Seen Jul 2026
  • Largest Value in Every Sliding WindowPHONE SCREEN · Seen Jul 2026

Similar questions at other companies

  • Binary Tree Preorder TraversalMorgan Stanley · PHONE SCREENMorgan Stanley interview questions
  • Binary Tree Inorder TraversalBloomberg LP · PHONE SCREENBloomberg LP interview questions
  • Validate a BST with a Custom ComparisonApple · PHONE SCREENApple interview questions
  • Find File Paths in a Directory TreeUber · PHONE SCREENUber interview questions
  • Delete a Filesystem TreeDatadog · PHONE SCREEN · ONSITE INTERVIEWDatadog interview questions
  • Serialize and Deserialize a Binary TreeNVIDIA · PHONE SCREENNVIDIA interview questions
  • Kth Smallest Value in a BSTExpedia · PHONE SCREEN · ONSITE INTERVIEWExpedia interview questions
  • Kth Smallest Element in a BSTNutanix · PHONE SCREENNutanix interview questions
  • Recover a Tree from Preorder Depth EncodingSuperhuman · PHONE SCREENSuperhuman interview questions
  • Binary Tree Preorder TraversalAnduril · ONSITE INTERVIEWAnduril interview questions

Interview reports that mention this question

  • Adobe Product Intern Interviews: 15 Experiences (Part 3 of 4)
  • Adobe CS1 Interviews: 14 Experiences (Part 4 of 6)

Adobe interview experiences

  • Adobe Web, QA, DevOps, ML Roles: 13 Experiences (Part 3 of 3)
  • Adobe SWE Interviews, Level Unknown: 25 Experiences (Part 2 of 3)
  • Adobe Interviews, Level Unknown: 38 Experiences (Part 1 of 3)
  • Adobe New Grad MTS Interview Questions: 7 Experiences
All Adobe interview questionsSee Adobe hiring insights
Saved
/**
 * Definition for a binary tree node.
 * public class TreeNode {
 *     int val;
 *     TreeNode left;
 *     TreeNode right;
 *     TreeNode() {}
 *     TreeNode(int val) { this.val = val; }
 *     TreeNode(int val, TreeNode left, TreeNode right) {
 *         this.val = val;
 *         this.left = left;
 *         this.right = right;
 *     }
 * }
 */
class Solution {
    public List<Integer> inorderValues(TreeNode root) {
        // Write your code here.
    }
}
Checking account…