2-3 and 2-3-4 trees. Understand how to search and insert. Understand why insertion technique leads to perfect balance.
Terminology. Know that a 2-3 tree is also called a B-Tree of order 3 and that a 2-3-4 tree is a B-Tree of order 4. Know that an M-node is a node with M children, e.g. a 4-node is a node containing 3 items and thus with 4 children.
Performance of trees. Tree height is between logM N and log2 N. All paths are of the same height.
1-1 correspondence between LLRBs and 2-3 trees. Understand how to map a 2-3 tree to an LLRB and vice versa. You do not need to know how to perform tree operations 'natively' on an LLRB.
LLRBs. BST such that no node has two red links touching it; perfect black balance; red links lean left.
LLRB get. Exactly the same as regular BST get.
LLRB performance. Perfect black balance ensures worst case performance for get and insert is ~ 2 log_2 N.
LLRB insert. You are not responsible for knowing how to insert into an LLRB using rotations and color flipping. However, you should know how to convert back and forth between 2-3 trees and LLRBs, and you should also know how to insert into 2-3 trees. Thus, you should know effectively how one can insert into an LLRB.
- Draw the 2-3 tree that results when you insert the keys A B C D E F G in order.
- Draw a 2-3 tree with all 3 nodes. Why is the height log_3(N)? Draw the corresponding left-leaning red black tree (LLRB).
- How many compares does it take in the worst case to decide whether to go left, middle, or right from a 3 node?
- Draw the LLRB tree that results when you insert the keys A B C D E F G in order.
- Given an LLRB, is there exactly one corresponding 2-3 tree? Given a 2-3 tree, is there exactly one corresponding red-black tree?
- What is the worst case height of a 2-3-4-5 tree? Best case? Give your answers in tilde notation.
- For a 2-3 tree of height N, what is the best case number of compares to find a key? The worst case?
- What is the worst case height of an LLRB? Give your answer in tilde notation. Draw an example of a worst case tree.
- Problem 2 of my Spring 2013 midterm, part b only.
- Problem 5 of the Fall 2014 midterm.
- Derive a simple procedure for deleting from a 2-3 tree. Your procedure must take O(log N) time.
- Show that in the worst case, we need to perform at most log N LLRB operations (color flips and rotates) after an insert. Give an example of a tree and an item X such that insertion of X requires log N LLRB operations.
- Problem 3 from Algs4Part1.