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 03 · DSA · Worked, and deeper · about 20 min to read

Play it as a journeyTutor comes with a plan

Trees, Worked (rotations, B-trees, range trees)

Rotations and Range Trees
Rotations and Range Trees · Open board

What it shows, before any of it is named: a small swap that straightens a leaning tree, two rulebooks for when to make that swap, the same swap’s cousin for a tree stored on disk, and one more tree built for a different question entirely.

Before you start. You need a binary search tree: a box holding one key, pointing at up to two others, smaller keys down the left and bigger down the right, so left-or-right at each step narrows the search. Trees (BST, balancing, heaps, tries) built that and asked you to trust that balance keeps it fast: this lesson is the proof, by hand.

Lesson 23 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

  • A tree that quietly turned into a list
  • 1972 and 1978, at Xerox PARC: the trick invented, and renamed
  • The one move under every fix: a rotation
  • Two rulebooks for when to rotate
  • The same idea, moved onto a disk
  • A different question: totals over a range that keeps changing

Terms it explains: rotation, AVL, Red-black, B-tree, segment tree, right rotation, left rotation, invariant, balance factor, B+tree, associative, Lazy propagation, Fenwick tree, lowest set bit.

Review DSA