# lec6 - MIT OpenCourseWare http/ocw.mit.edu 6.006...

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

MIT OpenCourseWare http://ocw.mit.edu 6.006 Introduction to Algorithms Spring 2008 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms .

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

View Full Document
Lecture 6 Hashing II: Table Doubling, Karp-Rabin 6.006 Spring 2008 Lecture 6: Hashing II: Table Doubling, Karp-Rabin Lecture Overview Table Resizing Amortization String Matching and Karp-Rabin Rolling Hash Readings CLRS Chapter 17 and 32.2. Recall: Hashing with Chaining: 1 . . . . U k k k k k 1 2 3 4 k . . . 4 k . k 2 k 3 all possible keys n keys in set DS Cost : Θ (1+α) h table m slots collisions expected size α = n/m } Figure 1: Chaining in a Hash Table Multiplication Method: h ( k ) = [( a k ) mod 2 w ] ( w r ) · where m = table size = 2 r w = number of bits in machine words a = odd integer between 2 w 1 and 2 w 1
Lecture 6 Hashing II: Table Doubling, Karp-Rabin 6.006 Spring 2008 w k a x } r } w-r keep ignore ignore + product as sum lots of mixing Figure 2: Multiplication Method How Large should Table be?

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