TAOCP Vol 3: Sorting and Searching · Week 110
TAOCP 6.2.2 Binary Tree Searching
Updated
Summary
TAOCP 6.2.2 Binary Tree Searching: Binary search trees: insertion, deletion, the average cost of random BSTs, and optimal BSTs built with dynamic programming when access frequencies are known. Budget about 8 hours; do exercises 1, 3 and 10.
This week's steps
3 stepsRead §6.2.2 Binary Tree Searching
Implement BST insert, search and delete with tests.
Start with Ex 1, Ex 3, Ex 10; log what you solve below.
Write down one thing you'd explain to someone
A few sentences in your own words in Your notes: the idea, why it works, an example. 30 words ticks this.
Sign in to track this: tick each step off and it counts toward your week.
Exercises
This section has 49 exercises, rated 15 to M47, and Knuth marks 12 of them with the triangle for recommended. Implement Algorithms T and D, then check exercises 13 and 16 empirically before proving them. The optimum-tree exercises (22 to 33) pair well with coding Algorithm K. 29 and 48 are research-level or open.
Worth your time
Exercise 320▶ Recommended
Can a sentinel speed up tree search the way it sped up sequential search?
Exercise 1022▶ Recommended
Keep a search tree efficient on nonrandom input by making it look random.
Exercise 1422▶ Recommended
Show the extra deletion step never lengthens paths, and find a case where it helps.
Exercise 23M23▶ Recommended
Find an optimum search tree for a skewed weight set without a computer.
Your log
Sign in to log the exercises you work: number, rating, how far you got.
Your notes
Only youSign in to keep private notes on this guide, in Markdown. They stay yours: never on your profile, and you can export them all.
Discussion
0 postsQuestions about the reading go here; each exercise has its own thread below. Hints over answers.
No posts yet. Ask a question or share a tip.
Sign in to postAnyone can read. Posting needs an account with a confirmed email.
Exercise threads
One thread per exercise. Open one to ask for a nudge or check your thinking.
Exercise 115No posts yet
Hints over answers. Say what you tried; put an answer or a full solution inside a spoiler:
||like this||or a```spoilerblock.Sign in to postAnyone can read. Posting needs an account with a confirmed email.
Exercise 320No posts yet
Hints over answers. Say what you tried; put an answer or a full solution inside a spoiler:
||like this||or a```spoilerblock.Sign in to postAnyone can read. Posting needs an account with a confirmed email.
Exercise 1022No posts yet
Hints over answers. Say what you tried; put an answer or a full solution inside a spoiler:
||like this||or a```spoilerblock.Sign in to postAnyone can read. Posting needs an account with a confirmed email.
Exercise 13M23No posts yet
Hints over answers. Say what you tried; put an answer or a full solution inside a spoiler:
||like this||or a```spoilerblock.Sign in to postAnyone can read. Posting needs an account with a confirmed email.
Exercise 1422No posts yet
Hints over answers. Say what you tried; put an answer or a full solution inside a spoiler:
||like this||or a```spoilerblock.Sign in to postAnyone can read. Posting needs an account with a confirmed email.
Exercise 1625No posts yet
Hints over answers. Say what you tried; put an answer or a full solution inside a spoiler:
||like this||or a```spoilerblock.Sign in to postAnyone can read. Posting needs an account with a confirmed email.
Exercise 23M23No posts yet
Hints over answers. Say what you tried; put an answer or a full solution inside a spoiler:
||like this||or a```spoilerblock.Sign in to postAnyone can read. Posting needs an account with a confirmed email.
Exercise 4530No posts yet
Hints over answers. Say what you tried; put an answer or a full solution inside a spoiler:
||like this||or a```spoilerblock.Sign in to postAnyone can read. Posting needs an account with a confirmed email.
Reference
Why it matters
BSTs are the basis of ordered maps. The optimal BST algorithm is a classic dynamic programming example.
Before you start
- 2.3 Trees
- 6.2.1 Searching an Ordered Table
How to approach it
Implement BST insert, search and delete with tests. Then implement the optimal BST dynamic program and check it on a small set of words with frequencies.
Common traps
- Deletion of a node with two children is the classic bug spot.