


















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
The concept of open addressing in hash tables, specifically focusing on linear probing, quadratic probing, and double hashing as collision resolution strategies. It includes examples, advantages and disadvantages, and guidelines for choosing a hash function and managing clustering. The document also touches upon cryptographic hash functions and their applications.
What you will learn
Typology: Lecture notes
1 / 26
This page cannot be seen from the preview
Don't miss anything!
Data Structures and Algorithms
Our running time in practice depends on ๐. What do we do when ๐ is big? Resize the array!
Operation Array w/ indices as keys put(key,value) best O(1) average O(1 + ฮป) worst O(n) get(key) best O(1) average O(1 + ฮป) worst O(n) remove(key) best O(1) average O(1 + ฮป) worst O(n) Average Case: Depends on average number of elements per chain Load Factor ฮป If n is the total number of key- value pairs Let c be the capacity of array Load Factor ฮป = ๐ ๐
Insert the following values into the Hash Table using a hashFunction of % table size and linear probing to resolve collisions 1, 5, 11, 7, 12, 17, 6, 25 111 12 255 6 177
Insert the following values into the Hash Table using a hashFunction of % table size and linear probing to resolve collisions 38, 19, 8, 109, 10 (^8 10388 ) Problem:
2
(^18 ) Insert the following values into the Hash Table using a hashFunction of % table size and quadratic probing to resolve collisions 89, 18, 49, 58, 79, 27 (^58 ) (79 % 10 + 0 * 0) % 10 = 9 (79 % 10 + 1 * 1) % 10 = 0 (79 % 10 + 2 * 2) % 10 = 3 Problems: If ฮปโฅ ยฝ we might never find an empty spot Infinite loop! Can still get clusters 27 Now try to insert 9. Uh-oh
If the table size is a prime number ๐, then the first ๐/ 2 probes check distinct indices.
Insert the following values into the Hash Table using a hashFunction of % table size and quadratic probing to resolve collisions 19, 39, 29, 9 39 29 9 19 Secondary Clustering When using quadratic probing sometimes need to probe the same sequence of table cells, not necessarily next to one another
<- Most effective if g(k) returns value relatively prime to table size
Effective if g(k) returns a value that is relatively prime to table size
What are the running times for: insert Best: ๐( 1 ) Worst: ๐(๐) (we have to make sure the key isnโt already in the bucket.) find Best: ๐( 1 ) Worst: ๐(๐) delete Best: ๐( 1 ) Worst: ๐(๐)
CSE 332 SU 18 โ ROBBIE WEBER