Hash Table


  1. Viewing the algorithm

  2. Insert, find, and delete functions

  3. Restrictions and other issues

  4. ChainHash

Viewing the algorithm

After starting a hash algorithm, a table such as the one above will appear (ChainHash is different and will be discussed later).  Each index in the table is labeled to the left of the index.  In the text field labeled "Messages Displayed Here," a description of each step of the algorithm is displayed.  To clearly view each step, the algorithm should either be run at a very slow speed or run in step mode.  The hash function is displayed in the next text field.  As the algorithm runs, the actual hash function used to place or find the key will be displayed.  In the next text field, the mode is displayed.  The algorithm can be in running, suspended, or step mode.  Note that once the initial set of insertions are done, the program may be in running mode, but nothing is happening.  The program is waiting for the user to run an insert, find, or delete.

Insert, find, and delete functions

The insert, find, and delete functions are located at the top of the frame.  They will not respond to the user until the program is done with the initial set of insertions.  After that, the user may enter a number in one of the text fields at the top and press the corresponding button to insert, find, or delete.  The button must be pressed in order to run the operation, pressing 'enter' does not do anything.  If the input is not legal, a message will appear telling the user to correct the input.  These operations must be run one at a time.  If the user tries to run one of these while another one is still running, a warning will be displayed to finish the other process first.

Restrictions and other issues

Only 50 items may be in the hash table at a time.  After that no more insertions may be performed until the user successfully deletes a number from the table.

As the hash table becomes full, it takes the find and delete methods longer to discover that a key is not in the table.  The way that they know a key is not in the table is if they run across an index that has never contained a value.  If all indexes have contained a value, the program uses some special conditions to determine that the key is not in the table. (Does not apply to ChainHash)

ChainHash

ChainHash has some differences from the other hash algorithms.  The hash table is in a single column so that the list may be displayed with greater ease.  There is no limit to how many inserts may be done, though too many inserts in one index may result in the list being drawn off of the screen.