More B-trees, Hashing and Secondary Storage




CS157b

Chris Pollett

Feb 14, 2018

Outline

Introduction

B-Tree Leaf Node
An B-tree Leaf Node.
B-Tree Internal Node
An internal B-tree Node.

Domain of Application of B-trees

Lookup in B-Trees

For simplicity we will assume no duplicate keys. To search for a record with key K:

In-Class Exercise

B-Tree for In-Class Exercise

Use the algorithm of the previous slide to step-by-step explain how the record with key 19 would be looked up in the B-tree above.

Post your solution to the Feb 14 In-Class Exercise Thread.

Range Queries

Insertion into B-Trees

B-Tree Insertion Example 1 B-Tree Insertion Example 2

Deletion from B-Trees

B-Tree for In-Class Exercise B-Tree Deletion Example 1 B-Tree Deletion Example 2 B-Tree Deletion Example 3

Efficiency of B-Trees

Secondary-Storage Hash Tables

Insertion, Deletion and Efficiency

Extensible Hash Tables

Insertion into Extensible Hash Tables

  1. Compute `h(K)` look at first `i` bits.
  2. Suppose this equals `x`.
  3. Look up the `x`th entry in the indirection table, follow its pointer to a bucket.
  4. If there is room insert into this bucket.
  5. If no room and the number of bits of hash value used to look up bucket way less than `i`, say `j`, divide entries in block `x` into two blocks according to the `j+1`st bit of the hash function.
  6. If `j=i` then we double the number of indirection pointers. That is set `i:=i+1`. Each old pointer on `i` bits now becomes two pointers on `i+1` bits. Now we can go to 3.

Linear Hash Tables