This exercise is for your own practice, not to be turned in. I highly recommend that you test yourself to see if you can reconstruct the solution from class.
The goal of this exercise is to understand separate chaining. It corresponds to Project 6.2 in the book, with a couple of additions.
Find the project code for this at
/homes/tvandrun/Public/cs345/hashing
.
This is the same code base as for the next two projects.
The code contains packages adt
,
impl
, and test
.
Your task is to complete the following methods:
find()
, a helper method that, given a key,
returns the pair (ie, node) containing that key, or
null
if none exists.
(The solution is on pg 321).
put()
, to add a new association to
the map, or overwrite an existing one.
(The solution is on pg 322).
remove()
, which removes a key and its
value from the map, if it exists.
This corresponds to Project 6.10.a in the book.
iterator()
, which returns an iterator
for the keys of this map.
This is a difficult iterator.
Recommended state variables for the iterator itself
are a Pair
variable referring to the
node whose key will be returned by the next call to next()
and an int
variable referring to the bucket
that pair is in.
This corresponds to Project 6.10.b in the book.
Nothing needs to be turned in.
You can find a solution in
/homes/tvandrun/Public/cs345/sepchain-soln
.