{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# ch12 - Chapter 12 Hash Table Review Hash Tables Factorial...

This preview shows pages 1–6. Sign up to view the full content.

Chapter 12 – Hash Table • Review Hash Tables • Factorial Integer Hashing String Based Hash Functions Storage and Retrieval • Collisions Linear Probing Double Hashing Separate Chaining • Buckets Hashing Analysis Hashing Discussion

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Review So far we have seen a number of ADTs for storing and retrieving data. The search times for these ADTs vary significantly.
Review ADT Search Time array O(N) – unsorted O(logN) – sorted linked list O(N) – sorted or unsorted stack O(1) – for top only queue O(1) – for head/tail only binary tree O(logN) – for any value heap O(logN) – for largest value

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Hash Tables A hash table is a data structure invented for very fast data storage and retrieval. Goal is to look for data in 1 step using the data itself to tell you where to look. We use a hash function to map data values into table positions. eg: hash(“john”) = 42 so we store “john” in position 42. john 0 1 2 42 Hash functions are many to one, so we need an algorithm to resolve collisions (where 2 values map to the same table position).
Integer Hashing Assume that we want to store/retrieve 100 student records by their ID. We could allocate an array 1,000,000 long use ID as the index, but this would waste a lot of space. Instead, we can allocate an array 200 long and use ID % 200 as our hash function.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern