Map Hash Tables and Dictionaries_Part_5

# Map Hash Tables and Dictionaries_Part_5 - Map Methods 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 - 21 - Map Methods with Separate Chaining Delegate operations to a list-based map at each cell: Algorithm get( k ): Output: The value associated with the key k in the map, or null if there is no entry with key equal to k in the map return A [ h ( k )] . get( k ) {delegate the get to the list-based map at A [ h ( k )]}

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 - 22 - Map Methods with Separate Chaining Delegate operations to a list-based map at each cell: Algorithm put( k,v ): Output: Store the new (key, value) pair. If there is an existing entry with key equal to k , return the old value; otherwise, return null t = A [ h ( k )] . put( k,v ) {delegate the put to the list-based map at A [ h ( k )]} if t = null then { k is a new key } n = n + 1 return t
Last Updated: 06/02/12 10:23 PM CSE 2011 Prof. J. Elder - 23 - Map Methods with Separate Chaining Delegate operations to a list-based map at each cell: Algorithm

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 ]}

### Page1 / 5

Map Hash Tables and Dictionaries_Part_5 - Map Methods 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