Index

Free, with Google

Keep going, free.

A free account opens lessons 2 and 3 of every track, 33 more lessons, and keeps your progress and review cards on every device.

Start free with Google

A chalk plan

Open everything on chalk.

Every lesson, board, video, lab and paper, and the full review decks. Yearly is $39/year.

See plansStart free instead

Module 01 · DSA · The toolbox · about 20 min to read

Play it as a journeyTutor comes with a plan

Trees (BST, balancing, heaps, tries)

Trees
Trees · Open board

Six numbers arranged as a chart: one at the top, two below it, three below those, and nothing loops back. The ordered counterpart to Hashing‘s buckets, and the shape behind the B-trees in Storage Engines.

Before you start. You already have the hash table from Hashing: instant lookup, no memory of order. This lesson is the opposite trade, a shape that remembers order, at the cost of one extra comparison per step.

Lesson 6 of 96 in DSA

The rest of this lesson is part of a plan.

A plan opens every lesson, board, video, lab and paper on chalk. Yearly is $39/year.

See plansAlready a member? Sign in

Or start free: a free account opens lessons 2 and 3 of every track.

In this lesson

  • 1857: a mathematician names the shape
  • 1875: the same shape, counting molecules
  • 1960: the shape learns a rule
  • The catch: the wrong order turns the tree into a line
  • 1962: a fix that never lets it lean
  • 1964: a different question
  • 1960, the same year: a shape that spells
  • One shape, three rules
  • Binary search tree, in numbers
  • Heap, in numbers
  • Trie, in numbers
  • The structure-choice map
  • Classic pitfalls

Terms it explains: tree, root, leaves, node, binary search tree, O(log n), heap, priority queue, trie, O(h), in-order, Traversals, pre-order, post-order, level-order, Data Systems callback, B-tree, disk, peek-min O(1), insert O(log n), extract-min O(log n), not sorted, steps, chars/node, question you ask most, base case, balanced, binary tree, BST, complete tree, height h, rotation, self-balancing BST (AVL / red-black), sift up/down, traversal.

Review DSA