Code

The measuring harness

The test passes — your Put, Keys, Range, Min, Max and Height are correct. Now you measure the tree.

Two files in this step, both complete. They are not your task: the harness is scaffolding, not the exercise.

treebench.go — three new commands:

command what it does
algo alpha step 1's answer: the walk, Min/Max, a range
algo tree the tree against lesson 10's hash index and lesson 1's linear scan
algo shape the same library, two insertion orders

And main.go — three lines, as always: the commands into usage and into the switch.

First run

Step 1's command is now yours:

$ algo gen -n 1000 -seed 3
$ algo alpha -n 6 -from Bam -to Bat

The same six titles you saw in step 1 should appear, and a range query that visited only 11 nodes out of 1,000. Lesson 10's algo ordered paid for the same list with a full sort of all 1,000 keys.