Held Friday, April 21, 2000
Overview
Today we revisit our project so that we can clarify a variety
of important issues.
Notes
- Today is the last day of prospective visits.
- HW5 is due today. That will be your last homework assignment. However,
I do expect you to continue thinking about the material in class.
- Make sure to turn in a printed copy.
- We'll spend most of today's class on the project.
- For Tuesday: Get your part of the project working (using stub classes
from the other parts).
- For the following Monday: Integrate; write a 3-5 page guide to your
part of the project; present.
- Team International has added stub classes. I hope the rest of you
will, too.
Contents
Summary
- Designing hash functions
- Handling conflicts in hashing
- Supporting deletion in hash tables
- What do you do when you try to insert an object into a hash table,
and there's already an object at the position (but with a different
key)?
- You can keep a linked list (or other structure) in each position,
and add to that structure.
- You can find another place in the table for the object by
changing the hash value.
- You can expand the hash table.
- The ``list'' method requires us to provide a dynamic data structure
for each cell of the table. It also means that the cost for
getting an element also involves searching through the structure.
- The ``advance'' method requires us to do more than one ``step'' when
looking up a value (as we might need to repeatedly skip
already filled spaces).
- The ``resize'' method requires us to grow the table regularly, and at
a significant cost (proportional to the number of elements in the
table).
- It also doesn't help if two distinct keys always end up with
the same value, as in our Wells/Gallagher example.
- The ``advance'' method also assumes a limited number of objects will
be placed in the table. when you delete an object, you need to
consider whether one of the objects in other cells really belonged there.
- There are a number of ways you can compute the ``next'' space in
the second method.
- You can offset by a fixed amount.
- You can use a second function to determine the offset (making
the offset object-dependent).
- You can can use a sequence of hash functions.
- ...
- Despite all this joyous freedom, I'll admit that I prefer the
``list'' method.
- We'll use today and next Friday to resolve issues having to do with
the project.
- My suggestion is that we try a walk through in the middle of the
game.