CSC152 2005F, Class 50: Lab on Lists
Admin
* Questions on the exam?
* Yes, I'll do some sample recurrence relations *tomorrow*
* To put a Heap, h into a Vector, v
* Number the nodes in the heap from 0 to n-1
* Put the value in each node in the appropriate cell of the vector
* Math tells us that the left child of the node #i is at position 2*i+1 and the right child is at 2*i+2
* Should put in sets add duplicate elements?
* No. Size should remain the same.
* For the hash table problem, what should we use for the size
of the table and what should we use as the keys?
* Support any size table
* Support any kind of key (simply call
(Math.abs(key.hashCode())) % tableSize;
* How do you handle null values w/o exceptions?
if (foo == null) {
// Special code for the null case
}
else {
// Normal case
foo.whatever();
}
/Questions on Lists?/
/Try the lab on Vector-based lists/
Overview
* Questions?
* Lab, part one: Vector-based lists
* Lab, part two: Doubly-linked lists (forthcoming)