Map Hash Tables and Dictionaries_Part_6

# Map Hash Tables and Dictionaries_Part_6 - Remove with...

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

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 Ø

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

View Full Document
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
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

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.

## This note was uploaded on 02/14/2012 for the course CSE 2011Z taught by Professor Elder during the Fall '11 term at York University.

### 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
Ask a homework question - tutors are online