Map Hash Tables and Dictionaries_Part_5

Map Hash Tables and Dictionaries_Part_5 - Map Methods 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 - 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 )]}
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 - 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
Background image of page 2
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
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.

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_5 - Map Methods 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