CST 8130 Data Structures Lab 6 Hashing Algorithms Purpose Demonstrate use of: · Use of good class construction including packages, javadoc & comments and other industry best practices · Use of file...

1 answer below »

CST 8130 Data Structures
Lab 6 Hashing Algorithms
    Purpose
    Demonstrate use of:
· Use of good class construction including packages, javadoc & comments and other industry best practices
· Use of file I/O with secondary storage along with custom-built hash table
    Task
     Read a .csv file, store the data in a hash table, then test it.
 
 ______________________________________________________________________________________________________________
 
Detailed requirements:
· You are provided with a .csv file containing the postal code prefixes for Ottawa and su
ounding towns/neighbourhoods in Ontario.
· Each line of the file co
esponds to one postal code prefix.
· There is only 1 field per line.
· And you provided with a main() class which opens the .csv file, reads each line and displays it on the “console”. (You can change the main() class).
· Your task is to:
· Create a class that implements a hash table.
· For your collision resolution strategy choose either “buckets” or “external chaining”
· You may use the A
ayList or LinkedList classes from the Java
Collections Framework to help implement your collision resolution strategy.
·
·
· The table size must be 25
· The hash table should make use of a generic type
(worth 2 marks out of 10)
·
·
· For your hash function use:
int h = key.hashCode();
h = h % tableSize;
tableSize is the size of the table (e.g. 25)         if (h < 0) { h = -h; }
 
·
· Input the .csv file
· Store each of the postal code prefixes in the hash table.
·
·
· You will need to code a method such as add(key)
· Test your hash table using a loop and generate 10 random postal code prefixes. Determine whether each is present in the hash table or not.
·
·
· The code to generate a random postal code prefix is given to you as part of the starter files.
· You will need to code a method such as contains(key) which returns a boolean
 
· Your output must look like the Sample Output (screenshot provided on Brightspace).
· The actual values may differ, but your output must look like the Sample Output
· Hint: use System.out.printf() for all output
·
1.
 
Coding requirements:
 
·
·
· follow the Java Coding Conventions as your "style guide"
· create at least 2 classes
· name of the class with the main() method must end in "Test"
· create at least 2 packages
· the main() method should perform all I/O
· there is no end-user input, there should only be output
· export your Eclipse project as a .zip
· name your folder using the convention:
Lab6_Firstname_Lastname.zip
· example: Lab6_James_Mwangi.zip
· Similarly, be sure to name your project following the convention:
            Lab6_Firstname_Lastname
· and submit your solution via Brightspace
 
Note:
· You will lose marks if you do not:
· follow the instructions under Detailed Requirements
· including any API features or algorithms described
· meet the Coding requirements
· ensure there are complete Javadoc comments for all public constructors and methods.
· produce the same output as the Sample output
 
 
Grading Scheme 
    Grading Item
     Marks
    Coding standards: at least classes, at least packages, formatting, naming conventions
    2
    Hashtable class (co
ect access specifiers, constructors and methods), table size = 25, hash table makes use of a generic type
    2
    Main method performs all File I/O: generates the similar output
    2
    Collision resolution strategy: A
ayList or LinkedList used
    2
    Comments (class headers, code comments, Javadoc), co
ectly named submission folders,  able to explain own code
    2
    Total
    10
 
 Best of Luck

Answered Same DayApr 06, 2022

Solution

Sandeep Kumar answered on Apr 06 2022
12 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here