CSC152 2005S, Class 41: Hash Tables (lab) Admin: * Change in schedule * Today: Hash tables * Tuesday: Vectors * Wednesday: Go over the exam * Homework for tomorrow: Read documentation for java.util.Vector * If it links to interfaces, you may also have to read those interfaces * 1 unit extra credit for having your friends or family send my son a postcard * Reminder: Cool "convos" this week and next (extra credit) Overview: * Review of hash tables * Lab Warning! You'll get compiler warnings Review: * Hash table is an implementation of dictionaries * Goal: *Very* efficient (O(1)) * Strategy: * Convert the key (index) into an integer between 0 and "number of cells in the hash table - 1" inclusive * Shove the key/value pair into that cell. * If more than one key/value pair goes into a cell, chain them with nodes * The mechanism for converting an object into a number is called "a hash function" * In Java, every class *can* provide this method (and call it hashCode) SAM, I NEED HELP PRINTING THE HASH TABLE! (1) Write a printNode method that takes a Node as a parameter and prints (a) the key/value pair and (b) any subsequent nodes Note that you will need recursion for this method. (2) Write a for loop that, for each cell of the table, calls printNode for (int i = 0; i < this.table.length; i++) { ... }