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.

Give a <strong>Java</strong> description of the values() <strong>and</strong> entries() methods that could<br />

be <strong>in</strong>cluded <strong>in</strong> the hash table implementation of Code Fragments 9.3–9.5.<br />

R-9.11<br />

Expla<strong>in</strong> how to modify class HashTableMap given <strong>in</strong> Code Fragments 9.3–<br />

9.5, so that it implements the dictionary ADT <strong>in</strong>stead of the map ADT.<br />

R-9.12<br />

Show the result of rehash<strong>in</strong>g the hash table shown <strong>in</strong> Figure 9.4 <strong>in</strong>to a table of<br />

size 19 us<strong>in</strong>g the new hash function h(k) = 2k mod 19.<br />

R-9.13<br />

Argue why a hash table is not suited to implement an ordered dictionary.<br />

R-9.14<br />

What is the worst-case time for putt<strong>in</strong>g n entries <strong>in</strong> an <strong>in</strong>itially empty hash table,<br />

with collisions resolved by cha<strong>in</strong><strong>in</strong>g? What is the best case?<br />

R-9.15<br />

Draw an example skip list that results from perform<strong>in</strong>g the follow<strong>in</strong>g series of<br />

operations on the skip list shown <strong>in</strong> Figure 9.12: remove(38), <strong>in</strong>sert(48,x),<br />

<strong>in</strong>sert(24,y), remove(55). Record your co<strong>in</strong> flips, as well.<br />

R-9.16<br />

Give a pseudo-code description of the remove operation <strong>in</strong> a skip list.<br />

R-9.17<br />

What is the expected runn<strong>in</strong>g time of the methods for ma<strong>in</strong>ta<strong>in</strong><strong>in</strong>g a maxima set<br />

if we <strong>in</strong>sert n pairs such that each pair has lower cost <strong>and</strong> performance than one<br />

before it? What is conta<strong>in</strong>ed <strong>in</strong> the ordered dictionary at the end of this series of<br />

operations? What if each pair had a lower cost <strong>and</strong> higher performance than the<br />

one before it?<br />

R-9.18<br />

Argue why location-aware entries are not really needed for a dictionary<br />

implemented with a good hash table.<br />

Creativity<br />

C-9.1<br />

576

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

Saved successfully!

Ooh no, something went wrong!