Notes for week 6 first lecture. hash table organization

----[ Mon, March 17 ]----

hash tables: Separate Chaining, Linear Probing, basic organization of hash functions.

  • Theorem (see 5..2 - however I do NOT expect you to know the proof of 5..2). If unsigned ints hashed are uniformly random, and n < half of array length is maintained by resizing when necessary, then the expected time of each find, add, remove operation is O(1). Insert letters of "homecoming" in a hash table of size 16 then do some find's, remove's, add's.
    Hash values: h-1 o-1 m-4 e-5 c-0 i-11 n-0 g-13 b-2 z-1
    
    '+' = add, '-' = remove, '?' = find, '.' = null, '*' = del. 
    
    loc:0 1 2 3 4 5 6 7 8 9 a b c d e f  return #probes
    ---------------------------------------------------
    +h: . h . . . . . . . . . . . . . .    t       1
    +o: . h o . . . . . . . . . . . . .    t       2
    +m: . h o . m . . . . . . . . . . .    t       1
    +e: . h o . m e . . . . . . . . . .    t       1
    +c: c h o . m e . . . . . . . . . .    t       1
    +o: c h o . m e . . . . . . . . . .    f       1
    +m: c h o . m e . . . . . . . . . .    f       2
    +i: c h o . m e . . . . . i . . . .    t       1
    +n: c h o n m e . . . . . i . . . .    t       4
    +g: c h o n m e . . . . . i . g . .    t       1
    -o: c h * n m e . . . . . i . g . .     o      2
    ?n: c h * n m e . . . . . i . g . .     n      4
    ?b: c h * n m e . . . . . i . g . .     .      5
    ?z: c h * n m e . . . . . i . g . .     .      6
    +b: c h b n m e . . . . . i . g . .    t       6
    -g: c h b n m e . . . . . i . * . .     g      1
    
    clickers