01Chapter 1: Trees and their vocabularyA tree is a hierarchical data structure made of nodes connected by edges. Unlike a general graph, a tree has no cycle: there is exactly one path between any two nodes. A tree with one node has no edges but is still a valid tree.2 min read
02Chapter 2: Binary trees and their special formsAssume you know basic recursion, object references, arrays, linked lists, and Big-O notation. This chapter uses height measured in edges. Thus, a one-node tree has height 0, and an empty tree has height -1.2 min read
03Chapter 3: Node, leaf, and height formulasAssume you know basic recursion, object references, arrays, linked lists, and Big-O notation. This chapter uses a binary tree, where each node has at most two children.3 min read
04Chapter 4: Linked and array representationsThis chapter assumes basic programming with functions and recursion, object references, arrays, linked lists, and Big-O notation. A binary tree is a collection of nodes where each node has at most two children: a left child and a right child. The representation determines how those nodes and child r2 min read
05Chapter 5: Preorder, inorder, postorder, and level orderAssume you know basic recursion, queues, object references, and Big-O notation. A tree traversal is a systematic way to visit every node exactly once. The traversal name describes when the algorithm visits a node relative to its left and right subtrees.1 min read
06Chapter 6: Rebuilding a tree from two traversalsAssume you know recursion, arrays, object references, and the meanings of preorder and inorder traversal. This chapter uses binary trees with distinct keys. Distinct keys matter because a key must identify exactly one position in the inorder sequence.2 min read
08Chapter 8: The binary search tree propertyAssume you know recursion, object references, and the meaning of Big-O notation. A binary search tree (BST) is a binary tree that keeps keys in an order that makes searching possible.2 min read
09Chapter 9: Searching a BSTAssume you know recursion, object references, and Big-O notation. A binary search tree (BST) stores keys so that, for every node:2 min read
10Chapter 10: Inserting into a BSTAssume you know recursion, object references, arrays, linked lists, and Big-O notation. This chapter uses the binary search tree property to insert a new key while preserving the tree's ordering.2 min read
11Chapter 11: Inorder traversal yields sorted keysAssume you know recursion, object references, and the binary search tree (BST) property. A BST stores every key smaller than a node in its left subtree and every key larger than the node in its right subtree. This chapter explains why inorder traversal of such a tree produces keys in sorted order.2 min read
12Chapter 12: Deleting from a BSTAssume you know recursion, object references, linked lists, and Big-O notation. Let the BST contain distinct keys. Its property is:2 min read
13Chapter 13: Cost of BST operations and the role of heightAssume you know recursion, object references, linked lists, and Big-O notation. Also assume the binary search tree property: keys smaller than a node are in its left subtree, and larger keys are in its right subtree.2 min read
14Chapter 14: Counting BSTs with Catalan numbersThis chapter assumes that you know recursion, binary search tree (BST) ordering, arrays, and Big-O notation. We count structurally different BSTs that contain the same set of distinct keys.2 min read
15Chapter 15: Keeping a BST balanced: AVL treesAssume you know binary search trees, recursion, references, and Big-O notation. The key issue is that a BST operation follows one root-to-leaf path, so its cost is proportional to the tree's height. An AVL tree is a BST that automatically limits this height after every insertion and deletion.2 min read