23.11.2014 Views

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

What is the worst-case runn<strong>in</strong>g time for <strong>in</strong>sert<strong>in</strong>g n key-value entries <strong>in</strong>to an<br />

<strong>in</strong>itially empty map M that is implemented with a list?<br />

R-9.2<br />

Describe how to use a map to implement the dictionary ADT, assum<strong>in</strong>g that the<br />

user does not attempt to <strong>in</strong>sert entries with the same key.<br />

R-9.3<br />

Describe how an ordered list implemented as a doubly l<strong>in</strong>ked list could be used<br />

to implement the map ADT.<br />

R-9.4<br />

What would be a good hash code for a vehicle identification number, that is a<br />

str<strong>in</strong>g of numbers <strong>and</strong> letters of the form "9X9XX99X9XX999999," where a<br />

"9" represents a digit <strong>and</strong> an "X" represents a letter?<br />

R-9.5<br />

Draw the 11-entry hash table that results from us<strong>in</strong>g the hash function, h(i) + (2i<br />

+ 5) mod 11, to hash the keys 12,44, 13, 88, 23, 94, 11, 39, 20, 16, <strong>and</strong> 5,<br />

assum<strong>in</strong>g collisions are h<strong>and</strong>led by cha<strong>in</strong><strong>in</strong>g.<br />

R-9.6<br />

What is the result of the previous exercise, assum<strong>in</strong>g collisions are h<strong>and</strong>led by<br />

l<strong>in</strong>ear prob<strong>in</strong>g?<br />

R-9.7<br />

Show the result of Exercise R-9.5, assum<strong>in</strong>g collisions are h<strong>and</strong>led by quadratic<br />

prob<strong>in</strong>g, up to the po<strong>in</strong>t where the method fails.<br />

R-9.8<br />

What is the result of Exercise R-9.5 when collisions are h<strong>and</strong>led by double<br />

hash<strong>in</strong>g us<strong>in</strong>g the secondary hash function h ′(k) = 7 − (k mod 7)?<br />

R-9.9<br />

Give a pseudo-code description of an <strong>in</strong>sertion <strong>in</strong>to a hash table that uses<br />

quadratic prob<strong>in</strong>g to resolve collisions, assum<strong>in</strong>g we also use the trick of<br />

replac<strong>in</strong>g deleted entries with a special "deactivated entry" object.<br />

R-9.10<br />

575

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!