Map Hash Tables and Dictionaries_Part_6

Map Hash Tables and Dictionaries_Part_6 - Remove with...

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

View Full Document Right Arrow Icon
Last Updated: 06/02/12 10:23 PM CSE 2011 Prof. J. Elder - 26 - Remove with Linear Probing Suppose we receive a remove(44) message. What problem arises if we simply remove the key = 44 entry? Example: h ( x ) = x mod 13 Insert keys 18, 41, 22, 44, 59, 32, 31, 73, in this order 0 1 2 3 4 5 6 7 8 9 10 11 12 41 18 44 59 32 22 31 73 k h(k) i 18 5 5 41 2 2 22 9 9 44 5 6 59 7 7 32 6 8 31 5 10 73 8 11 Ø
Image of page 1

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

View Full Document Right Arrow Icon
Last Updated: 06/02/12 10:23 PM CSE 2011 Prof. J. Elder - 27 - Removal with Linear Probing To address this problem, we introduce a special object, called AVAILABLE , which replaces deleted elements AVAILABLE has a null key No changes to get (k) are required. Algorithm get ( k ) i h ( k ) p 0 repeat c A [ i ] if c = Ø return null else if c.key () = k return c.element () else i ( i + 1) mod N p p + 1 until p = N return null
Image of page 2
Last Updated: 06/02/12 10:23 PM CSE 2011 Prof. J. Elder - 28 - Updates with Linear Probing remove ( k ) We search for an entry with key k If such an entry ( k, o ) is found, we replace it with the special item AVAILABLE and we return element o
Image of page 3

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

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