manual

Document Sample
manual Powered By Docstoc
					     Hashing Animation Tool
Administration and Operating Manual
              CIS 495
           August 20, 2000
          Catalyst Software
             Fadi Aoude
             Doug Code
            Ann VanDyne
                               Table of Contents

Introduction                                        2
Purpose of product                                  2
       Operating environment                        2
General functionality                               3
       Special features                             4
       Limitations                                  4
       Documentation conventions                    4
Installation                                        4
        Physical requirements                       4
        Copying and backup                          5
        Software installation                       5
        Customizing product                         5
Tutorial                                            5
        Walkthrough example                         5
        Explanation of example                      6
        Using help (on-line and text                8
Detailed Instruction                                8
       Output from product                          8
       Input to product                             9
       Operation of product                        10
       Error handling                              10
       Specific functions                          10
               How to run                          11
               Input data needed                   15
               Output interpretation               15
Technical Details                                  15
       Principles of operation                     15
       Advanced features                           18
       Modification of product                     18
       Support information                         19




                                       1
Introduction

This manual contains information on installing and running the Hashing Animation Tool.

Purpose of Product
The Hashing Animation Tool is a web based Java applet that is designed to serve as a
learning aid for students in lower level Computer and Information Science classes. Using
the interactive software, students can study and compare the performance of several
hashing algorithms and observe the effects of changing table, data and execution
parameters. The following hashing algorithms are demonstrated by the applet:

      Linear probing
      Quadratic probing
      Bucket chaining
      Linked list chaining
      Chaining with separate overflow

After the user enters specifications for the hash table, numerical input, and execution
mode the applet will animate the storage or retrieval of the data. As the demo runs, the
user may display the pseudocode for the algorithm. In this mode, lines of code are
highlighted in synchronization with the animation to demonstrate the algorithm logic.
The user may alternatively elect to display statistics that are continuously updated as the
algorithm executes.

Tabular setup and statistics summaries are provided for up to five runs. These allow the
user to compare the performance of different algorithms or the same algorithm with
different settings. In addition, the applet will also display plots of average time and
average probes as a function of table load.

Operating Environment
The Hashing Animation Tool is implemented as a web based Java applet. After the
applet files are downloaded to the client machine, a Java-enabled web browser that
supports Java 1.1 is required to execute them. Examples of web browsers that support
Java 1.1 are Internet Explorer 4+ and Netscape Navigator 4+. Since the Java bytecode is
interpreted using the Java Virtual Machine, the applet is platform independent.




                                             2
General Functionality
The major inputs and outputs for the applet are listed below.

1. The hashing algorithm is selected from the drop-down menu on the toolbar. The five
   supported algorithms are:

       a)   Linear probing (default)
       b)   Quadratic probing
       c)   Bucket chaining
       d)   Linked list chaining
       e)   Chaining with separate overflow

2. Clicking the Setup button displays the Setup page. This page shows the current setup
   parameters for the currently selected algorithm. The user is not required to enter any
   of the algorithm setup parameters since each algorithm is initialized with default
   values. In general, however, users will want to change these settings to suit their own
   interests. The user may modify any of the following for the selected algorithm:

       a) Table settings
       b) Data settings
       c) Execution settings

3. Clicking the Options button displays the Options dialog. This dialog box allows the
   user to:

       a) Adjust execution speed
       b) Toggle the sound off and on

4. The Execution Page displays the animated storage or retrieval of data from the hash
   table. In addition, this page presents a continuously updated display of the current
   input value, demo progress and various statistics. The user has the option of
   replacing the statistics with a list box showing pseudocode for the algorithm. As the
   demo runs, lines of code are highlighted in synchronization with the animation. The
   following controls are available from the Execution Page:

       a) Select between Run, Step, Pause, and Abort demo execution
       b) Toggle between pseudocode and statistics displays

5. The Results page allows the user to view and edit summaries of up to five completed
   demos. Inputs on this page consist of:

       a) Mouse clicks on displayed summaries to select or deselect them
       b) Delete and Undelete buttons to edit the summaries displayed




                                              3
6. The Plot page displays average time and average probes plots for selected summaries.
   Inputs on this page consist of:

         a) Mouse clicks on displayed summaries to select or deselect them
         b) Time, Probes, and Both buttons to select the graphs displayed


Special Features
Special features of the applet include:

1.   Animation of storage or retrievals from the hash table
2.   Synchronized display of pseudocode logic
3.   Adjustable execution speed
4.   Tabular and graphical display of demo statistics

Limitations
Limitations of the applet include:

        The absolute maximum number of data elements that can be displayed is 300.
         The maximum varies according to which algorithm is selected and the
         configuration of the hash table. For example, more values can be displayed when
         using three-slot buckets than when using one-slot buckets.
        The data values are limited to the range 0 to 999.

Document Conventions

        Table of contents for faster information access
        Main section headings are bold and use 16 point Arial font
        Section sub-headings are normal and use 16 point font
        Indented lists are used for improved readability



Installation

Physical Requirements
Since the applet actually executes on the client computer, the web server requirements are
minimal. The server must have sufficient free disk to hold the applet and HTML files
(approximately 150Kb) and a fast enough Internet connection to support simultaneous
downloads.



                                             4
Copying and Backup
The product does not create or modify any files. Backup of the product is recommended,
however, in order to restore the Java class files in the event any of them are corrupted.
All product files, including the source code, are small enough to be backed up on a single
1.44MB floppy disk.

Software Installation
All the Java class files and sound files for the product have been compressed into a single
JAR (Java Archive) file for faster downloading. This file and the applet and help HTML
files are found in the WEB directory of the provided floppy disk. Simply copy the three
files into a new or existing directory on the web server. Finally, create a link to the applet
HTML file on an existing or new web page.

Note:
The entire source code for the applet is supplied in the SOURCE directory of the floppy
disk. All required sound files are in the SOUNDS directory. These files are provided so
that the applet may be modified and re-archived at a later date. In addition, this manual is
located in the MANUAL directory.

Customizing Product
The product was not designed to be customized. Customization is limited to adjusting
the displayed size of the applet by changing its HEIGHT and WIDTH parameters within
the applet’s HTML file.



Tutorial

Walkthrough Example
The following example leads the user through the steps necessary to run one store and
one retrieve demo and to display tabular and graphical results.

   1. When the applet loads in the browser it displays an animated title screen and a
      toolbar along the bottom. Select the quadratic probing algorithm from the drop-
      down menu.
   2. The Setup page shows the current settings for the algorithm. Click the Change
      button for the Table Setup section and read the instructions in the Notes box.
   3. Change the value in the Slots per bucket textfield from 2 to 3 and click the Next
      button.




                                              5
   4. Read the instructions in the Note box, check the Use nearest prime checkbox and
       click OK.
   5. Click the Change button for the Data Setup section.
   6. Change the Upper limit value to 500, the Data type to Odd and click OK.
   7. Click the Execute button on the toolbar.
   8. Click the Run button on the toolbar.
   9. Observe the animation and statistics for 3 or 4 seconds.
   10. Click the Pause button.
   11. Click the Options button on the toolbar and adjust the slider on the displayed
       dialog box all the way to the left.
   12. Click the Run button, wait a few seconds and the click the Pause button.
   13. Click the Source Code button below the statistics table.
   14. Click the Step button a few times.
   15. Move the animation delay slider back to the right and Click the Run button.
   16. When the demo has completed click the Setup button.
   17. Select linked list chaining from the drop-down menu on the toolbar.
   18. Click the Change button for the Execution Mode section.
   19. Change the Execution mode menu from Store to Retrieve.
   20. Change the Percent successful from 50 to 75.
   21. Check the Quick load checkbox and Click OK.
   22. Click the Execute button on the toolbar.
   23. Click the Step button one time.
   24. Click the Run button and allow the demo to run a few seconds.
   25. Click the Abort button.
   26. Click the Run button and allow the demo to run to completion.
   27. Click the Results Button on the toolbar.
   28. Click anywhere on the column labeled “1” to highlight the data.
   29. Click the Delete button on the toolbar.
   30. Click the Undelete button on the toolbar.
   31. Click the Plot button on the toolbar.
   32. Click on the row labeled “1” to highlight the text and plot the data.
   33. Click on the row labeled “2” to highlight the text and plot the data.
   34. Click the Time button on the toolbar.
   35. Click the Probes button on the toolbar.


Explanation of Walkthrough Example
The following explains the steps outlined in the example above:

   1. The drop-down menu on the toolbar is used to select the algorithm that will be
      demonstrated.
   2. The Setup page shows the current settings for the algorithm. Each algorithm has
      its own unique settings. The Setup page will display the default settings for the
      algorithm or the settings entered the last time the Setup page for the algorithm



                                           6
    was modified. Clicking the Change button for a section displays instructions for
    that section in the Notes box.
3. This sets the number of slots each bucket of the hash table will have.
4. The number of slots and buckets are edited independently for display purposes.
    For example, more one-slot buckets will fit on the screen than three-slot buckets.
    The applet needs to know the number of slots being used in order to set the limit
    on the allowable number of buckets. The Use nearest prime checkbox sets the
    number of buckets to the prime value nearest to the number in the buckets
    textfield.
5. The Data Setup section is similar to the Table Setup section except that the data
    settings are independent and may all be changed at once.
6. This sets the maximum value that may be stored in the table to 500. The Data
    type selection specifies that all values stored in the table will be odd.
7. The Execute button displays the hash table to be used by the current algorithm.
8. Clicking the Run button generates 75 random odd values less than 500 and begins
    hashing them into the table. Empty slots are gray, slots containing values are
    purple and buckets being probed are outlined in yellow.
9. Observe how the home address is displayed for each input value and how the
    statistics are updated as the algorithm progresses.
10. Clicking the Pause temporarily suspends the algorithm execution.
11. The slider on the Options dialog determines how fast the algorithm executes.
    This dialog also provides the means for turning the sound on and off.
12. This step shows how slowing the speed down makes the displayed events easier
    to follow.
13. This toggles the pseudocode for the quadratic probing store algorithm into view.
14. Using the Step button allows the user to correlate a line of pseudocode with a
    displayed animation step.
15. Decrease animation delay so the demo will finish in a reasonable amount of time.
16. When a demo has completed the page buttons will be enabled on the toolbar.
17. Selects linked list chaining as the next demo to run and updates the Setup page
    display.
18. This time we use the default Table and Data settings and change the Execution
    mode.
19. Changes the Execution mode menu from Store to Retrieve.
20. In retrieve mode, the percentage of the data size that will be found in the table is
    specified.
21. Selects the quick load option so the user doesn’t have to watch or step through the
    loading of the hash table prior to running the retrieve algorithm.
22. Displays the Execute page.
23. When using Quick Load the loading of the table is accomplished in one step and
    without animation.
24. The algorithm runs continuously as it did in Store mode.
25. Clicking the Abort button exits the current demo and resets the execution back to
    a ready state.
26. This step allows the demo to run quickly to completion.




                                         7
   27. Clicking the Results Button displays the Results Page. This page can display
       settings and statistics summaries for up to five completed runs.
   28. Clicking a column that contains data selects that summary. Clicking it again
       deselects it.
   29. Clicking the Delete button removes any selected summaries from the display.
   30. Clicking the Undelete button restore deleted runs one at a time if there is room on
       the page to display them. Up to five deleted runs may be restored.
   31. The Plot button displays the Plot page.
   32. This plots the data for the first summary. The text for the demo is highlighted in
       the same color as its data on the graph. The interpretation of the x-axis differs
       depending on whether data was stored or retrieved. The number of asterisks
       displayed in the Run column indicates which of the x-axis labels applies to the
       run.
   33. This plots the data for the second summary in a different color for easy
       comparison.
   34. Clicking the Time button shows a larger version of the Average Time plot shown
       in the previous step.
   35. Clicking the Probes button shows a larger version of the Average Probes plot
       shown in steps 32 and 33.

Using Help (online and text)
Help for the Hashing Animation Tool is provided in the form of a HTML help file. The
web page is accessed by clicking the Help button on the applet’s toolbar. In addition, a
text link to the file is provided below the applet. This link directs the user to the
Operating Requirements portion of the help page and is meant to assist a user who has
difficulty displaying the applet. The rest of the help file includes sample instructions,
suggestions for running the demos and sections providing information on each of the five
algorithms and the four main displays. Hyperlinks to these sections are arranged as
menus at the top and bottom of the document to assist users in locating the information
they desire.



Detailed Instruction

Output From Product
The output from the product falls into three categories:

   1. Animated demos of the five hashing algorithms
   2. Tabular statistics summaries listing the following results:
          Execution time – the time required to execute the demo.
          Probes - the average number of bucket and node searches per value that
             the algorithm attempted to store or retrieve.


                                             8
           Load Factor - the number of values in the table divided by the table
            capacity. The table capacity equals: buckets x slots + size of separate
            overflow.
         Successful searches - if a value was successfully stored or retrieved from
            the table it counts as a successful search.
         Unsuccessful searches - when the algorithm finishes the sum of the
            successful and unsuccessful searches will equal the data size.
   3. XY Plots of:
       Average Time - the average number of seconds required for each value the
        algorithm attempted to store or retrieve
          Average Probes – the average number of bucket and node searches per
           value that the algorithm attempted to store or retrieve
       The interpretation of the x-axis depends on if the algorithm was storing or
       retrieving data. For storage runs, the plots are functions of average table
       load factor. Retrieve demos, however, plot data as functions of the current
       number of values searched over the total number to search (the data size).
Input to Product
Each of the inputs used by the applet are listed below.

   1. The hashing algorithm to demonstrate is selected using the drop-down menu on
      the toolbar.
   2. Display commands (Setup, Execute, Results, or Plot) are entered using the
      Display buttons on the toolbar.
   3. Table setup parameters are entered using the following controls:
       The number of slots per buckets textbox
       The number of buckets textbox
       The use nearest prime option checkbox
       The size of the overflow table textbox (if applicable)
   4. Data setup parameters are entered using the following controls:
       The upper limit textbox
       The data size textbox
       The data type textbox
   5. Execution setup parameters are entered using the following controls:
       The execution mode drop-down menu (store or retrieve)
       The percent successful textbox (retrieve only)
       The quick load option (retrieve only)
   6. Execution commands (Run, Step, Pause, Abort) are entered using the Execution
      buttons on the toolbar.
   7. Pseudocode and Statistics displays are toggled using the Source Code and
      Statistics button on the lower right portion of the Execution display.
   8. Runs are selected on the Results and Plot pages by left-clicking on them using the
      mouse.



                                             9
   9. Edit summary commands (Delete, Undelete) are entered using the Edit results
       buttons on the toolbar.
   10. Plot view commands (Time, Probes, Both) are entered using the Plot views
       buttons on the toolbar.
   11. The Options dialog is accessed using the Options button on the toolbar. Inputs for
       this dialog include:
        Sound option checkbox
        Animation speed slider control
   12. The Help Page is accessed using the Help button on the toolbar.

Operation of Product
The product has five basic operations:
   1. Select an algorithm
   2. Enter the setup parameters
   3. Execute the demo
   4. View the results
   5. View the plots

The user initiates each of these steps using the controls on the applet. The applet is event
driven, allowing the user greater flexibility in using the tool. For example, the user does
not have to execute the five operations in order. A user may choose to use the default
settings for an algorithm and execute three demos of that algorithm in a row before
viewing the results. The user is restricted from performing certain operations at certain
times. For example, the user may not enter new setup parameters while a demo is
running. All controls that are not currently available for use are disabled or hidden.

Error Handling
The applet receives input from the user via drop-down menus, buttons, checkboxes,
mouse clicks and textboxes. The first four methods automatically restrict input values to
the required ranges. Input to text boxes should be integers and limited to the range listed
to the right of the box. Java exception handlers are used to catch any exceptions caused
by parsing strings that do not represent integers. Integer input is then tested to ensure it is
within the specified range. The applet responds to any invalid textbox entry by setting
the textbox color to red, playing an error sound and displaying a message to the user.

Specific Functions
The applet demonstrates five hashing algorithms. Each algorithm requires the same type
of input, is executed in the same manner, and results in the same type of output.




                                              10
How to Run

  1. Select an algorithm from the drop-down menu or click the Setup button if you
     wish to use the algorithm currently displayed in the menu.
  2. The Setup page shows the current settings for the selected algorithm. If you wish
     to change a setting, click the Change button for the appropriate section, enter the
     new setting(s) and click the OK button. Instructions for each input are provided
     in the Notes display. When you are finished, click the Execute button on the
     toolbar.
  3. The Execution page displays the hash table, hash function, execution progress and
     the statistics table. To view the algorithm pseudocode instead of the statistics,
     click the Source Code button. Click the Statistics button if you wish to toggle
     back.

     To begin the demo click either the Step or Run button. If the Statistics table is
     showing, the Step button will execute one table search or insertion. If the
     pseudocode is displayed, it will execute the action corresponding to the
     highlighted line of code. Click Step again for the next action or click the Run
     button to animate the demo to completion. To adjust the speed of the animation
     or disable the sound, click the Options button and set the controls in the pop-up
     dialog box. Clicking the Pause button while a demo is running halts the execution
     and allows you to switch back to Step mode if desired. Clicking Abort resets the
     execution display back to its start state. After executing one or more demos, click
     the Results button.
  4. The Results page displays tabular summaries of up to five completed runs. Here
     you can compare the performance of different algorithms or settings. To delete a
     run, click on any of its summary fields to select it and click the Delete button.
     Clicking the Undelete button restores any deleted summaries one at a time if there
     is room to display them. Next, click the Plot button.
  5. The Plot page allows you to plot Average Time and Average Probes as functions
     of Average Table Load Factor for storage and as functions of numbers
     searched/total numbers for retrieval. To plot a run, click on its summary row with
     the mouse. The summary text will change color and will match its corresponding
     data on the graph. This page allows three possible views of the two plots: two
     small plots, one large time plot or one large probes plot. Click either the Time,
     Probes or Both button on the toolbar to display the desired view.

  You are not restricted to performing the steps in the order outlined above. Any button
  or control that is enabled may be used at any time.

  The section provides additional information about each of the applet displays.




                                          11
Setup Page

   Each algorithm is setup individually. When the Setup page is selected it will
   display the default settings for the current algorithm or the settings entered the last
   time the Setup page for that algorithm was modified.

   The range limits on the individual settings are interrelated and some of them are
   strictly for display purposes. For example, more one-slot buckets will fit on the
   screen than three-slot buckets. Therefore, if you increase the slots per bucket
   from one to three the applet may automatically reduce the number of buckets to
   ensure the table will fit on the screen. When this happens, the Notes area will
   display a message indicating that an adjustment was made and a notification
   sound will play (if sound is enabled). A similar adjustment will also occur if you
   make changes that reduce the capacity of the table to below that of the current
   data size setting.

   There are two options that are only available for Retrieve demos. Both are found
   in the Execution mode section of the page. The first allows you to specify the
   percentage of searches for data that will be successful. The second is a quick load
   option. For Retrieve demos, you may watch or step through the loading of the
   table prior to running the actual data retrieval. To skip this portion of the demo,
   select the quick load checkbox. The table will then be loaded with data prior to
   being displayed.

Execution Page

   Table Display

   The hash table uses different colors to indicate various states and actions. An
   empty bucket slot is gray. A slot that contains a value is purple. Links to other
   buckets are cyan. A link displaying a diagonal line indicates that the value of that
   pointer is null. Nodes of linked list chains are show in orange.

   When a bucket or node is searched, either to find an empty slot or to find a certain
   value, the border of the bucket or node is highlighted in yellow. A successful
   search for a value is indicated by displaying the slot or node containing the value
   in green.

   Due to display limitations, nodes of linked-list chains over a certain length will
   not be visible. In these cases, the last visible node will have a dashed link arrow
   to indicate there are additional nodes in the chain. This arrow will be shown in
   yellow to indicate when these additional nodes are being searched and it will be
   shown in green when a search is successful.




                                         12
   The text above of table indicates whether a store or retrieve demo is selected. It
   also indicates the current search status of the algorithm or whether the demo has
   finished executing.

   Hash Function Display

   The upper right portion of the Execution page indicates the current hash function.
   In all cases division hashing is used and the equation will be:
            home address = value mod (number of buckets)
   This display is updated as each value is stored or retrieved.

   Progress Display

   The progress display is immediately below the hash function. This display
   indicates how many values out of the data size specified during setup remain to be
   processed. The progress display is the only portion of the Execution page updated
   during a quick load.

   Statistics Display

   The following statistics are continuously updated as the demo executes:

         Time – the minutes, seconds, and centiseconds that have elapsed since the
          demo began. This data is obtained from your computer system’s clock
          and is not adjusted to account for animation speed or delays introduced by
          using the Step and Pause buttons.
         Average Probes – the average number of bucket and node searches per
          value that the algorithm attempted to store or retrieve.
         Load Factor – the number of values in the table divided by the table
          capacity. The table capacity equals: buckets x slots + size of separate
          overflow.
         Searches – if a value was successfully stored or retrieved from the table it
          counts as a successful search. When the algorithm finishes the sum of the
          successful and unsuccessful searches will equal the data size.

   Pseudocode Display

   This portion of the page shows the pseudocode for the current algorithm. As the
   demo runs the lines of code are highlighted in synchronization with the animation
   to demonstrate the algorithm logic. See the Algorithms section for more
   information about the individual collision resolution algorithms.

Results Page

   Any demo that is allowed to run to completion creates a summary listing that will
   be displayed on the Results page. Please note that the results displayed for a


                                        13
   retrieve demo do not include any of the probes, searches, etc. that occurred while
   the table was being loaded.

   The Results Page displays summaries for up to five runs. If additional demos are
   run, the summary displayed in column one will be lost, the remaining summaries
   shifted down and the new summary added to column five.

   You may delete any of the displayed summaries to make room on the page for
   new runs. To do this click any of the summary data for the runs you wish to
   remove and click the Delete button. Clicking the Undelete button restores deleted
   summaries one at a time if there is room to display them. Up to five deleted
   summaries may be restored.

Plot Page

   The Plot page allows you to plot Average Time and Average Probes for up to five
   demos. Average Time refers to the average number of seconds that elapsed for
   each value the algorithm attempted to store or retrieve. Similarly, Average Probes
   is the average number of bucket and node searches per value that the algorithm
   attempted to store or retrieve. The interpretation of the x-axis depends on if the
   algorithm was storing or retrieving data. For storage runs, the plots are functions
   of Average Table Load Factor. Retrieve demos, however, plot data as functions
   of the current number of values that have been searched for over the total number
   of values to be searched for (the data size).


Options Dialog

   The Options dialog is a pop-up window that is displayed when the Options button
   is clicked on the toolbar. This dialog allows you to enable or disable sound and to
   adjust the algorithm execution speed.

   Sounds are played under the following circumstances: to indicate an input error
   on the Setup page, to indicate the number of buckets or data size was
   automatically reduced, and to indicate successful and unsuccessful searches.

   The animation delay is controlled with a slider and sets the number of
   milliseconds the algorithm pauses after each action. Setting the delay to zero
   results in maximum execution speed. The execution will not appear instantaneous
   however, since the applet still requires a certain amount of time to refresh the
   elements displayed on the screen.




                                       14
Input Data Needed
The applet requires a minimum amount of input since all setup and execution parameters
are initialized with default values. A user could simply select an algorithm, click the
Execute display button, and click the Run button to execute a demo. In general, however,
the user will want to modify the setup data for an algorithm, use various execution
commands and view the results. Each of these input parameters is described in the Input
to Product section.

Output Interpretation
Output from the product consists of:
   1. Animated demos of the five hashing algorithms
   2. Tabular statistics
   3. XY plots of Average time and Average probes

The hash table uses different colors to indicate various states and actions. An empty
bucket slot is gray. A slot that contains a value is purple. Links to other buckets are
cyan. A link displaying a diagonal line indicates that the value of that pointer is null.
Nodes of linked list chains are show in orange.

When a bucket or node is searched, either to find an empty slot or to find a certain value,
the border of the bucket or node is highlighted in yellow. A successful search for a value
is indicated by displaying the slot or node containing the value in green.

Due to display limitations, nodes of linked-list chains over a certain length will not be
visible. In these cases, the last visible node will have a dashed link arrow to indicate
there are additional nodes in the chain. This arrow will be shown in yellow to indicate
when these additional nodes are being searched and it will be shown in green when a
search is successful.

The data presented in the tabular statistics and XY plots was described in the Output
from Product section.



Technical Details

Principles of Operation
Each of the five algorithms demonstrated by the applet are objects of classes that inherit
from the abstract class, HashAlgorithm. A Setup class object is defined for each of these
algorithms. The attributes of this class specify the table, input and execution parameters
needed to run the demo. These attributes are modified through the Setup page. When an



                                             15
algorithm runs, it sets the attributes of its corresponding Results object. These are the
values that are displayed as statistics and used to generate the XY plots.

The applet defines a HashAlgorithm variable called currentAlg. When an algorithm is
selected using the drop-down menu, currentAlg is set as an alias to the selected algorithm
object.

The applet implements a Runnable interface, meaning that a started Thread object will
execute the statements listed in the applet’s run method. Within the run method is a call
to currentAlg’s run method. When this call occurs, dynamic binding takes place and the
overridden run method in the algorithm object executes. It is the statements within the
specific algorithm’s run method that perform the storage or retrieval of data, animate the
screen and generate the results statistics.

The sections below provide additional information about the five collision resolution
algorithms the applet demonstrates. Each of the algorithms uses the same division hash
function to determine the home address. The collision resolution algorithms dictate the
actions taken when a value cannot be stored in its home address because it is already full.
Similarly, the approach taken when searching for data depends on the algorithm used to
store the data initially.

   Linear Probing

   If a collision occurs while trying to store a value at its home address, this algorithm
   moves forward through the table searching each bucket one by one until an empty slot
   is found. If the bottom of the table is reached, the search wraps around back to the
   beginning of the table and continues until either an empty slot is found or the search
   reaches its starting point, in which case the table is full. For the applet demo, the data
   size cannot exceed the table capacity; so all storage attempts will be successful.

   The retrieve algorithm also performs a wrap-around search starting at the home
   address. The search is considered unsuccessful if the algorithm encounters an empty
   slot or wraps around to the home address before finding the desired value.

   Quadratic Probing

   This algorithm is similar to linear probing except a different formula is used to
   calculate which address is searched next. This formula is:
        address = home address + i*i         where “i” is a zero-based search counter.
   If the value of an address exceeds the address of the bottom of the table, the search
   wraps around from address 0.
   There are variations of this algorithm that, with certain restrictions on the table and
   input, guarantee each bucket will be searched. The applet’s implementation does not
   impose these restrictions. Instead, the maximum number of searches it will perform
   for an empty bucket is equal to the number of buckets in the table. When this
   condition is reached the storage is considered unsuccessful. Retrieval is similar


                                             16
except that a search is also considered unsuccessful if an empty slot is encountered
prior to finding the value searched for.


Bucket Chaining

Storage using the bucket chaining algorithm requires two passes through the input
data set. On the first pass, the home address for a value is determined and the data is
inserted in the table if there is an available slot at this address. If there is a collision
however, the data is stored in a temporary data structure until the second pass.

The second pass works as follows:
For each value that wasn’t stored on the first pass, the algorithm checks the link of the
value’s home address. If the link is null, a wrap around linear probing search is done
for a completely empty bucket. If an empty bucket is found, the value is inserted and
the link of the home address is set to the address where the value was inserted. If the
link at the home address is not null, the algorithm searches for an empty slot in the
bucket pointed to by the link. If there is an empty slot the value is inserted. If this
bucket is also full and has a link that is not null, the next bucket in the chain is
searched. If the chain ends with a full bucket, the algorithm performs a wrap around
linear probing search for a completely empty bucket. If an empty bucket is found, the
value is inserted and the link of the last bucket in the chain is set to the address where
the value was inserted. Any wrap around search that returns to its origin is
considered unsuccessful.

The retrieve algorithm starts at the home address and searches each bucket in the
chain. The search is unsuccessful if an empty slot or a full bucket with a null link is
encountered prior to finding the value searched for.


Linked List Chaining

This algorithm always stores a data value at its home address. Data is inserted in the
bucket slots until the bucket is full. Subsequent values hashed to this address are
added as new nodes in the link list pointed to by the bucket. For the algorithm
demonstrated by the applet, new nodes are added to the front of the list.

The retrieve algorithm first searches the slots of the bucket at the home address. If
the value is not present, the algorithm searches each node of the linked list one by
one. The search is unsuccessful if the end of the chain is reached prior to finding the
value searched for.




                                           17
   Chaining with Separate Overflow

   This algorithm requires two hash tables. The hash function is based on the number of
   buckets in the primary hash table. All home addresses calculated by the hash
   function refer to the primary table. Data is inserted in the overflow table only if the
   home address in the primary table is full. The overflow table used in the applet demo
   is limited to one slot per bucket.

   If a collision occurs while trying to store a value at its home address, the algorithm
   checks the link at this bucket. If the link is null, the algorithm performs a linear
   probing search of the overflow table for an empty bucket starting at the first bucket in
   the table. If an empty bucket is found, the value is inserted and the link of the home
   address is set to the address in the overflow table where the value was inserted.

   If the link at the home address is not null, the algorithm searches the associated chain
   in the overflow table until the end of the chain is reached. At this point the algorithm
   performs a wrap around linear probing search for an empty bucket. If an empty
   bucket is found, the value is inserted and the link of the last bucket in the chain is
   pointed to this bucket’s address. Any wrap around search that returns to its origin is
   considered unsuccessful.

   The retrieve algorithm starts at the home address and searches each bucket in the
   chain. The search is unsuccessful if a full bucket with a null link is encountered prior
   to finding the value searched for.

Advanced Features
Advanced features of the applet include:

1. Animation of storage or retrievals from the hash table
2. Synchronized display of pseudocode logic
3. Adjustable execution speed
4. Tabular and graphical display of demo statistics

Animation was achieved using graphics double buffering and multithreading. Design and
implementation of the algorithm objects incorporated inheritance and dynamic binding.
Design and implementation of the HashTable and BucketSprite classes utilized
composition.

Modification of Product
The source code for this product is thoroughly commented, modular and written with
readability in mind. Using the store and retrieve methods of the existing algorithms as
templates, it should be straightforward for a programmer with some Java experience to
modify the existing algorithms or add new ones.



                                            18
Catalyst Software will consider any requests for minor modifications that are submitted
prior to May 1, 2001. Please send modification requests to: dougcode@umich.edu.

Technical Support
Catalyst Software will correct any bugs found and reported prior to May 1, 2001. Please
submit any bug reports to: dougcode@umich.edu.




                                           19

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:3
posted:1/16/2013
language:Unknown
pages:20