Presentation 1 PPT Computer Club
Presentation 1 PPT Computer Club
Presentation 1 PPT Computer Club
Presented by:
Mumal Rathore
Computer Club
What is Hashing?
Hashing in the data structure is a technique of mapping a large chunk
of data into small tables using a hashing function. It is a technique that
uniquely identifies a specific item from a collection of similar items.
Hash Table and Hash Function
A hash table is a generalization of the simpler notion of an ordinary array. Direct addressing
is applicable when we can afford to allocate an array that has one position for every possible key.
When the number of keys actually stored is small relative to the total number of possible keys, hash
tables become an effective alternative to directly addressing an array, since a hash table typically uses
an array of size proportional to the number of keys actually stored.
Instead of using the key as an array index directly, the array index is computed from the keys using
hash functions.
The "bottom line" is that hashing is an extremely effective and practical technique.
Why Hashing?
The fly in the ointment of this beautiful idea is that two keys may hash to the
same slot--a collision. Fortunately, there are effective techniques for resolving
the conflict created by collisions.
• Chaining
• Open Addressing:
Chaining
• In chaining, we put all
the elements that hash to
the same slot in a linked
list. Slot j contains a
pointer to the head of the
list of all stored elements
that hash to j; if there are
no such elements, slot j
contains NIL.
• CHAINED-HASH-INSERT(T, x)
insert x at the head of list T[h(key[x])]
• CHAINED-HASH-SEARCH(T, k)
search for an element with key k in list
T[h(k)]
• CHAINED-HASH-DELETE(T, x)
delete x from the list T[h(key[x])]
Open Addressing
Practice Questions:
GeeksforGeeks
LeetCode
Bibliography
• Introduction to Algorithms – THOMAS H. CORMEN, CHARLES E.
RONALD L. CLIFFORD STEINRIVESTLEISERSON
http://staff.ustc.edu.cn/~csli/graduate/algorithms/book6/chap12.htm
• https://www.geeksforgeeks.org/
Thank You!
LinkedIn | Computer Club