Hashing Exercises Hash Function v A good hash
- Slides: 57
Hashing Exercises
Hash Function v A good hash function should be: v Repeatable v Fast to compute (don’t want to add complexity) v Minimizes Collisions v Utilizes the whole range of the table
Hash functions v Repeatable Table Size: 100, 000 v Fast to compute (don’t Hashing A# want to add complexity) v Minimizes Collisions v Utilizes the whole range of the table int hash=A[3];
Hash functions v Repeatable Table Size: 100, 000 v Fast to compute (don’t Hashing A# want to add complexity) v Minimizes Collisions int hash=0; v Utilizes the whole for(int i=1; i<9; i++) range of the table hash+=A[i];
Hash functions v Repeatable Table Size: 100, 000 v Fast to compute (don’t Hashing A# want to add complexity) v Minimizes Collisions v Utilizes the whole range of the table int hash=rand()%100, 000;
Hash functions v Repeatable Table Size: 100, 000 v Fast to compute (don’t Hashing A# want to add complexity) v Minimizes Collisions int hash=0; v Utilizes the whole for(int i=1; i<9; i++) range of the table hash=hash*128+A[i];
Hash functions v Repeatable Table Size: 100, 000 v Fast to compute (don’t Hashing A# want to add complexity) v Minimizes Collisions int hash=0; v Utilizes the whole for(int i=1; i<9; i++) range of the table hash=hash<<7+A[i];
Exercises v Table Size 15 1) Linear Probe v Hash- mod 15 2) Quadratic Probe v Insert 16, 7, 28, 31, 3) Chaining 67, 28, 29, 73, 99, 43, 218 4) Double hash – %13 + 1
Exercise 1 0 v Linear probe v Insert 16, 7, 28, 31, 67, 28, 29, 73, 99, 43, 218 v How many probes? 1 2 3 4 5 6 7 8 9 10 11 12 13 14
Exercise 1 v Linear probe v Insert 16, 7, 28, 31, 67, 28, 29, 73, 99, 43, 218 v How many probes? v 22 0 73 1 16 2 31 3 43 4 5 6 7 7 8 67 9 99 10 218 11 12 13 28 14 29
Exercise 2 0 v Quadratic probe v Insert 16, 7, 28, 31, 67, 28, 29, 73, 99, 43, 218 v How many probes? 1 2 3 4 5 6 7 8 9 10 11 12 13 14
Exercise 2 0 v Quadratic probe v Insert 16, 7, 28, 31, 67, 28, 29, 73, 99, 43, 218 1 16 2 31 3 245 260 275 4 v How many probes? v 18 v 43 couldn’t insert (I went to 40) 73 5 6 7 7 8 67 9 99 10 11 12 218 13 28
Exercise 3 0 v Chaining v Insert 16, 7, 28, 31, 67, 28, 29, 73, 99, 43, 218 v How many probes? 1 2 3 4 5 6 7 8 9 10 11 12 13 14
Exercise 3 0 v Chaining v Insert 16, 7, 28, 31, 67, 28, 29, 73, 99, 43, 218 v How many probes? v 16 1 16 ->31 2 3 4 5 6 7 7 ->67 8 8 9 99 10 11 12 13 28 ->73 ->43 14 29
Exercise 4 0 v Double hash %13 + 1 v Insert 16, 7, 28, 31, 67, 28, 29, 73, 99, 43, 218 v How many probes? 1 2 3 4 5 6 7 8 9 10 11 12 13 14
Exercise 4 0 v Double hash %13 + 1 v Insert 16, 7, 28, 31, 67, 28, 29, 73, 99, 43, 218 v How many probes? 1 16 2 3 43 4 31 5 6 v 15 7 7 v Cannot insert 73 8 218 9 99 10 67 because 9*5 = 15*3 11 12 13 28 14 29
Clustering v Primary Clustering- Didn’t initially hash to same location, but had to compete for successive v Secondary Clustering- Hashed to the same place, and continued competing v Non-Clustering
Complete Heap v Insert 10, 105, 18, 9
Complete Heap 0 v Put it in the array 1 2 3 4 5 6 7 8 9 10 11 12 13 14
Complete Heap v Insert 10, 105, 18, 9 0 100 1 19 2 36 3 17 4 3 5 25 6 1 7 2 8 7 9 10 11 12 13 14
Complete Heap v Delete largest, then delete again for next largest
Complete Heap v Delete largest, then delete again for next largest 0 100 1 19 2 36 3 17 4 3 5 25 6 1 7 2 8 7 9 10 11 12 13 14
Leftist Heap v Are these leftist heaps?
Leftist Heap v Are these leftist heaps?
Leftist Heap v Merge
Leftist Heap v Insert 3
Leftist Heap v Insert 4
Leftist Heap v Delete
Skew Heap v Merge
Skew Heap v Insert 4
Skew Heap v Delete
Binomial Queue v Merge
Binomial Queue v Insert 12, 11, 28, 33
Binomial Queue v Delete
Binomial Queue v Delete
Binomial Queue v Delete
Leftist Heap v Merge
Leftist Heap v Merge
Leftist Heap v Merge
Leftist Heap v Merge
Leftist Heap v Merge
Leftist Heap v Merge
Leftist Heap v Merge
Leftist Heap v Merge
Leftist Heap v Merge
Skew Heap v Merge
Skew Heap v Merge
Skew Heap v Merge
Skew Heap v Merge
Skew Heap v Merge
Skew Heap v Merge
Skew Heap v Merge
Skew Heap v Merge
Skew Heap v Merge
Skew Heap v Merge
Skew Heap v Merge
Complete Heap v Is this a complete max heap? 0 100 1 89 2 36 3 17 4 67 5 35 6 19 7 4 8 7 9 43 10 59 11 28 12 23 13 21 14
- Modulo function c++
- Extendible hashing vs linear hashing
- Motivation for dynamic hashing
- Static hashing and dynamic hashing
- Tema de hash hash
- Algoritmo abcde
- Hashing exercises
- Load factor of hash table
- Good thought good words good deeds
- Hi hi good morning
- Good afternoon animado
- Nothing compares to your embrace
- Good morning good morning good afternoon
- Mid square hashing method
- Hashinny
- Two simple hash function
- Collision resistant hash function
- Spatial hash function
- Hash function code
- Separate chaining
- Olac fuentes
- Mh to hash
- One-way hash function
- Davies meyer construction
- Hashing struktur data
- Static hashing
- Spectral hashing
- Double hashing
- Manajemen kolisi
- Extendible hashing deletion
- Hash multiplication method
- Quadratic hashing
- Re-hashing
- Hashing collision resolution
- Alexandra stefan uta
- What is hashing in database management system
- 81mod23
- Hashing example
- Hashing pergeseran adalah
- Encoding encryption and hashing
- Dynamic perfect
- What is static hashing in dbms
- Consistent hashing load balancing
- Cisc 235
- Internal hashing techniques in dbms
- Probability theory in hashing and load balancing
- Hashing in dbms
- Quadratisches sondieren
- Difference between hashing and skip list
- Directoryless dynamic hashing
- Pengertian dari organisasi berkas langsung
- Hashing
- What is direct addressing in hashing
- Load density in hashing
- Extendible hashing visualization
- Cpsc 319
- Hash cerrado
- Hashing cerrado