recitation05

recitation05 - MIT OpenCourseWare http/ocw.mit.edu 6.006...

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

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

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

View Full Document Right Arrow Icon
6.006 Recitation Build 2008.10
Image of page 2
Coming Up Next... Hashing in theory and in Python Bad hash functions Mutable dictionary keys Hashes for basic data types in Python
Image of page 3

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

View Full Document Right Arrow Icon
Why Hashing Useless from a theoretical standpoint O(N) / op worst-case, not fit for proofs Used everywhere (dictionaries, indices) O(1) / op is smokin’ hot / fast Simple - small constant factor Relies on black magic
Image of page 4
Hashing pwns BSTs? BSTs O(lg(N)) / op guaranteed upper bound (worst-case) comparison model (an order relation on keys is sufficient) pwns in real-time Hashing O(1) / op avg-case no guarantees for worst-case -- O(N) intimate knowledge of keys (via magic inside the hash function) rocks for most cases
Image of page 5

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

View Full Document Right Arrow Icon
Real Life Hashing I Application: Keeping library cards 4x6” card for each book filing by the 1st letter of the book title e.g.“Differential Equations” goes to D no sorting asides from mechanism above
Image of page 6
Real Life Hashing II filing is uncool, let’s think of bucketing 26 buckets, labeled ‘A’ - ‘Z’ Books are bucketed by 1st letter in title Time to find a book ~ bucket size
Image of page 7

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

View Full Document Right Arrow Icon
Real Life Hashing III What sucks in the scheme above? Common prefixes “The ...”,“Introduction to...” Uneven distribution Many words start with E Few words start with X
Image of page 8
Real Life Hashing IV Solutions to issues above?
Image of page 9

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

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