

































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


































































Problem Set 6 and Final Project Proposals are due in the box up front. Problem Set 6 and Final Project Proposals are due in the box up front.
●
●
●
●
●
●
●
●
● (^) A chained hash table is a hash table in which collisions are resolved by placing all colliding elements into the same bucket. ● (^) To determine whether an element is present, hash to its bucket and scan for it. ● (^) Insertions and deletions are generalizations of lookups. Calliope Clio Polyhymnia Urania Erato Thalia Terpsichore Euterpe Melpomene
● The load factor of a chained hash table is the ratio of the number of elements ( n ) to the number of buckets ( m ). ● Typically denoted α = n / m. ● By doubling the table size whenever α exceeds two, α can be kept low with amortized O(1) work per insertion. ● With universal hash functions, the expected, amortized cost of a lookup is O(1).
●
●
●
●
● Cuckoo hashing is a simple hash table where ● Lookups are worst-case O(1). ● Deletions are worst-case O(1). ● Insertions are amortized, expected O(1). ● (^) Insertions are amortized O(1) with reasonably high probability. ● Today, we'll explore cuckoo hashing and work through the analysis.
● (^) Lookups take time O(1) because only two locations must be checked. ● (^) Deletions take time O(1) because only two locations must be checked. 32 93 58 84 59 97 23 53 26 41 T ₁ T ₂
● (^) To insert an element x , start by inserting it into table 1. ● (^) If h ₁( x ) is empty, place x there. ● Otherwise, place x there, evict the old element y , and try placing y into table 2. ● Repeat this process, bouncing between tables, until all elements stabilize. 53 10 58 6 75 97 23 84 26 32 93 T ₁ T ₂
● It's possible for a successful insertion to revisit the same slot twice. ● Cycles only arise if we revisit the same slot with the same element to insert. 58 75 97 23 84 26 32 93 T ₁ T ₂ 53 10 6 91
●
●
●
●
●
●
91 10 75 19 26 32 6 T ₁ T ₂ 53 16 88 58 16 10 58 91 53 6 26 19 88
●
●
91 10 75 19 26 32 6 T ₁ T ₂ 53 16 88 58 16 10 91 53 6 26 19 88 4 4 58
●
Each edge is an element and each node is a bucket. The arrows show which bucket each element belongs to. Each edge is an element and each node is a bucket. The arrows show which bucket each element belongs to.
●
If there are no cycles, eventually the displacement chain comes to rest. If there are no cycles, eventually the displacement chain comes to rest.