CSC 2200 Chapter Notes - Chapter 5: Hash Function

48 views3 pages
Chapter 5.1 Hashing
CSC 2200
Hashing
oImplementation of hash tables
oTechnique used for performing insertions, deletions, and finds constant average time
The ideal has table data structure is merely an array of some fixed size containing the items
Chapter 5.2 Hash function
1) int hash( const string & key, int tableSize )
2) {
3) int hashVal = 0;
4)
5) for( char ch : key )
6) hashVal += ch;
7)
8) return hashVal % tableSize;
9) }
Simple Hash function
1) int hash( const string & key, int tableSize )
2) {
3) return ( key[ 0 ] + 27 *key[ 1 ] + 729 * key[ 2 ] ) % tableSize;
4) }
Chapter 5.3 Separate Chaining
Separate chaining
oA strategy to keep a list of all elements that has to the same value
find more resources at oneclass.com
find more resources at oneclass.com
Unlock document

This preview shows page 1 of the document.
Unlock all 3 pages and 3 million more documents.

Already have an account? Log in

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents