DSA / Trees Interview Questions 2026

Published July 22, 2026 · Updated July 22, 2026

5 DSA / Trees interview questions from Google, Microsoft, Amazon, Apple and more. Real questions from Technical, System Design, and HR rounds.

5 questions
Companies: Google, Microsoft, Amazon, Apple

All DSA / Trees Questions

Google Medium Technical round JavaC++Python

Given a binary tree, return the boundary of the tree in anti-clockwise direction starting from the root. The boundary consists of the left boundary, leaves, and the right boundary in reverse.

↑ 96 upvotes · 31 engineers asked this · SDE2
Microsoft Easy Screening round

Given a binary search tree, find the kth smallest element. Optimize for the case where this function is called many times on a static tree.

↑ 67 upvotes · 41 engineers asked this · SDE1
Microsoft Medium Technical round JavaC#Python

Given a binary tree, print nodes level by level (BFS traversal). Then modify it to print alternate levels in reverse order (zigzag traversal). Analyse time and space complexity.

↑ 61 upvotes · 40 engineers asked this · SDE1
Amazon Medium Technical round JavaPython

Serialize and deserialize a binary tree. Implement both functions and explain why BFS serialization makes deserialization simpler than DFS. What is the time and space complexity?

↑ 44 upvotes · 27 engineers asked this · SDE1
Apple Medium Technical round SwiftJavaPython

Given a BST, find the closest value to a given target. Explain the O(log n) iterative approach using BST properties, and how the answer changes if the tree is unbalanced.

↑ 41 upvotes · 24 engineers asked this · SDE1

Practice these questions with AI feedback

Get instant grading on your answers, identify your weak areas, and generate a personalised 14-day study plan — all free.

Build my study plan →

Same topic at specific companies

Google DSA / Trees Microsoft DSA / Trees Amazon DSA / Trees Apple DSA / Trees

Related topics

DSA / Arrays System Design DSA / Graphs Behavioral Testing Domain DevOps API Testing DSA / Hashmaps GCP / Real-time Data Java / Pub-Sub React / Performance Node.js / Memory SQL / Query Optimization Python / Async AWS / Lambda Kafka / Consumer Microservices / Saga Pattern TypeScript / Type System MongoDB / Indexing Security / SQL Injection Performance / Latency Tail Redis / Cache Stampede Elasticsearch / Cluster Health GraphQL / Security Data Engineering / Exactly Once Snowflake / Architecture PySpark / Core Concepts Airflow / Scheduling Web / WebAssembly Debugging / Production JavaScript / V8 Engine

Frequently asked questions

Given a binary tree, return the boundary of the tree in anti-clockwise direction starting from the root. The boundary consists of the left boundary, leaves, and the right boundary in reverse.
Given a binary tree, return the boundary of the tree in anti-clockwise direction starting from the root. The boundary consists of the left boundary, leaves, and the right boundary in reverse.
Given a binary search tree, find the kth smallest element. Optimize for the case where this function is called many times on a static tree.
Given a binary search tree, find the kth smallest element. Optimize for the case where this function is called many times on a static tree.
Given a binary tree, print nodes level by level (BFS traversal). Then modify it to print alternate levels in reverse order (zigzag traversal). Analyse time and space complexity.
Given a binary tree, print nodes level by level (BFS traversal). Then modify it to print alternate levels in reverse order (zigzag traversal). Analyse time and space complexity.
Serialize and deserialize a binary tree. Implement both functions and explain why BFS serialization makes deserialization simpler than DFS. What is the time and space complexity?
Serialize and deserialize a binary tree. Implement both functions and explain why BFS serialization makes deserialization simpler than DFS. What is the time and space complexity?
Given a BST, find the closest value to a given target. Explain the O(log n) iterative approach using BST properties, and how the answer changes if the tree is unbalanced.
Given a BST, find the closest value to a given target. Explain the O(log n) iterative approach using BST properties, and how the answer changes if the tree is unbalanced.