Databases
Indexing: B+ trees and hashing
Why indexes speed up reads, and what a B+ tree node holds.
In two minutes
One idea to a line
A B+ tree keeps all records (or record pointers) in the leaves, which are linked for range scans. Internal nodes only guide the search.
For an internal node of order p: at most p pointers and p − 1 keys, and at least ⌈p/2⌉ pointers (except the root).
The tree is balanced, so every search takes the same number of block reads: the height. A high fan-out keeps the tree very shallow.
A hash index is excellent for equality lookups but cannot help range queries or ordering.
A clustered index decides the physical order of rows, so a table can have only one; secondary indexes can be many.
Slips people make here
Interviewers know them too
Putting data pointers in the internal nodes of a B+ tree (that is a B tree).
Using a hash index for a range query.
Counting keys when the question asks for pointers.
Your practice here
Not started
10 written questions, and 2 kinds of calculation that change every time
No answers yet