Map Hash Tables and Dictionaries_Part_6

Map Hash Tables and Dictionaries_Part_6 - Remove with...

Info iconThis 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 Ø
Background image of page 1

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

View Full DocumentRight 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
Background 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
Background image of page 3

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

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 5

Map Hash Tables and Dictionaries_Part_6 - Remove with...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online