Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

implement the symbol table that will be used by the assembler during pass 1 and

ID: 3552768 • Letter: I

Question

 implement the symbol table that will be used by the assembler during pass 1 and pass 2. It should be constructed as an efficient hashing table. You should construct a "main" routine that will invoke the symbol table operations. The main routine should read a file name off the command line.    p1 filename  where filename is any name of my chosing.  p1 is an ASCII linux shell script which contains instructions to run . For example, it may look like:  #!/bin/ksh java myprog $1  The file will consist of a character string and an optional number one per line. For example the file might look like:  moss 25 eno fred gorge 18  The actions should follow the following rules.  1) upon seeing        moss 25      hash moss creating a location in an array.      if moss already exists, report an error, for example:          (ERROR moss already exists at location 8)      if moss does not exist, store the name and its number          when moss is stored print a lines such as:  stored moss 25 at location 8 (where 8 is the array index where moss is stored reporting collisons, if necessary)                                     2) upon seeing eno      hash eno to find the location in the array where eno may            or may not exist.      if eno does not exist, report an error           (ERROR eno not found)      if eno does exist, report the location in the array and its number.           (eno found at location 12 with value 433)  Clearly, the 12 and 433 are numbers created for this example. 433 would have been the number associated with eno when it was stored, like 25 was the number associated with moss, in the above example.  You will have one printed line for each input line in the file. (Maybe more when printing the occurrence of collisions) You must be able to handle collisions. You must write a hashing function, you may not use one built in the language. 
 
 ====================================================================== 
 
 import java.io.*; //////////////////////////////////////////////////////////////// class DataItem { // (could have more data) private int iData; // data item (key) //-------------------------------------------------------------- public DataItem(int ii) // constructor { iData = ii; } //-------------------------------------------------------------- public int getKey() { return iData; } //-------------------------------------------------------------- } // end class DataItem //////////////////////////////////////////////////////////////// class HashTable { private DataItem[] hashArray; // array holds hash table private int arraySize; Open Addressing 535 private DataItem nonItem; // for deleted items // ------------------------------------------------------------- public HashTable(int size) // constructor { arraySize = size; hashArray = new DataItem[arraySize]; nonItem = new DataItem(-1); // deleted item key is -1 } // ------------------------------------------------------------- public void displayTable() { System.out.print(

Explanation / Answer