Skip to content

Resource · Guide or article

Tree cheatsheet for coding interviews

Focuses on binary trees and binary search trees, which the page says are what interviews usually ask about. It assumes you are comfortable with recursion.

Reviewed

Open the original: Tree cheatsheet for coding interviews (opens the original site in a new tab)

Practice this topicOpens the practice interviewer with a question on Trees.

Add to a roadmap

Keep this resource with a roadmap you follow. It appears as your own extra resource; the roadmap's steps don't change and it doesn't count toward your tracked steps.

Source content: English

A tree is a widely used abstract data type that represents a hierarchical structure with a set of connected nodes. Each node in the tree can be connected to many children, but must be connected to exactly one parent, except for the root node, which has no parent.

PrepKit overview

PrepKit editors wrote and reviewed this overview from the source repository. It is not text from the resource itself.

Suited to
The source does not state a level
Format
Cheatsheet

What it covers

  • Glossary covering ancestor, degree, depth, and width, plus complete and balanced binary trees.
  • In-order, pre-order, and post-order results on one sample tree, noting in-order alone cannot serialize a tree.
  • BST notes: in-order yields sorted output, validation comes up often, and traversal space is O(h).
  • Learn iterative traversals, because interviewers may ask for them after a quick recursive answer.
  • Level-order traversal with BFS and checking for negative values in path sums.

How to use it

PrepKit study advice, not a claim made by the source.

Write all three traversals recursively, then iteratively with an explicit stack, and check them against the page's sample tree results. Finish by validating a BST and testing it on a skewed tree.

Scope and limitations

No code samples. AVL, red-black, and B-trees appear only as optional reading links. Ends with an imported Recommended courses block whose links are not in the recorded file, so PrepKit has not reviewed them.

Access and format

Web page on techinterviewhandbook.org, free to read online in English; the text comes from the MIT-licensed yangshun/tech-interview-handbook repository.

Reviewed by PrepKit on Oct 2, 2026. Listing source commit: e1d28e8886c0

Evidence behind this overview
  • apps/website/contents/algorithms/tree.md

Related preparation

These are PrepKit study suggestions, not employer endorsements or predictions of interview questions.

Pages that include this

Get the PrepKit newsletter

Optional. You don't need it to use PrepKit.

How we handle your email