{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

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

View Full Document Right Arrow Icon
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
Image of page 1

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

View Full Document Right Arrow Icon
Review So far we have seen a number of ADTs for storing and retrieving data. The search times for these ADTs vary significantly.
Image of page 2
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
Image of page 3

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

View Full Document Right Arrow Icon
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).
Image of page 4
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.
Image of page 5

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

View Full Document Right Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    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.

    Student Picture

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

  • Left Quote Icon

    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.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    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.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern