Download presentation
Presentation is loading. Please wait.
Published byRanveig Espeland Modified over 5 years ago
1
CS223 Advanced Data Structures and Algorithms
Hashing Neil Tang 02/19/2008 CS223 Advanced Data Structures and Algorithms
2
CS223 Advanced Data Structures and Algorithms
Class Overview Basic idea Hashing functions CS223 Advanced Data Structures and Algorithms
3
CS223 Advanced Data Structures and Algorithms
Basic Idea Hash table is an array of some fixed size, containing the items. Each item has a key. Hashing is a technique used for performing insertions, deletions and searches in constant average time. Hashing is the implementation of hash tables. CS223 Advanced Data Structures and Algorithms
4
CS223 Advanced Data Structures and Algorithms
Basic Idea A hash function maps a key into some number in the range [0, TableSize-1]. An ideal hash function can distribute the keys evenly among the cells. Collision (two keys hash to the same value) is the major issue of hashing. CS223 Advanced Data Structures and Algorithms
5
CS223 Advanced Data Structures and Algorithms
An Example CS223 Advanced Data Structures and Algorithms
6
CS223 Advanced Data Structures and Algorithms
A Simple Hash Function If TableSize = 10007, the hash function can only assume values [0,127*8]. CS223 Advanced Data Structures and Algorithms
7
CS223 Advanced Data Structures and Algorithms
Another Hash Function Only 2851 combinations, i.e, only 28% of the table can be hashed to. CS223 Advanced Data Structures and Algorithms
8
CS223 Advanced Data Structures and Algorithms
The 3rd Hash Function CS223 Advanced Data Structures and Algorithms
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.