[SOLVED] SER222 Implementing Hashtable-based Symbol Tables
Описание
Download Link: https://assignmentchef.com/product/implementing-hashtable-based-symbol-tables/
Get your Assignment Solved:
https://assignmentchef.com/upload-assignment/
ser222 03 04 hw0
1 Background
In this assignment, you will practice applying your knowledge of ADTs and hashtables, to implement three
symbol table ADTs which use relatively standard hashing techniques. Most likely, these will be the most
conceptually complicated data types you build. Provided for you in the slides is LinearProbingHashST
and SeparateChainingHashST: sample implementations of linear probing and chaining approaches to implementing
a hash-based symbol table. Be sure to gure out how they work before attempting the hashtable
implementations for this assignment. We will be implementing three techniques for symbol tables:
TwoProbeChainHT: In a normal chaining approach, keys hash to exactly one index and the key/value
pair must reside in the list at that particular index. In this new approach, we will instead calculate two
hashes, that indicate two dierent indices, and then add the new key/value to whichever of two lists, at the
two indices, is the shortest. The result is that the chains will end up being shorter since we split in half
where the key/value pairs are placed.
LinearProbingHT: The idea is that we hash to a specic index in the internal array. If the index is
empty, we add the key/value pair to it. If occupied, we increment the index by 1 and try again. This repeats
until an empty index is found.
QuadProbingHT: This technique is very similar to LinearProbingHT, the dierence is that it uses a
quadratic function to select a target index.
Sample high level UML is shown in Figure 1. Note that your requirement is to follow the interface, not
the UML. (Hint: following the UML for the two Entry classes WILL save you a headache when initializing
the array of generics.)
This document is separated into four sections: Background, Requirements, Testing, and Submission.
You have almost nished reading the Background section already. In Requirements, we will discuss what
is expected of you in this homework. In Testing, we give some basic suggestions on how the hashtable
implementations can be tested. Lastly, Submission discusses how your source code should be submitted on
Canvas.
2 Requirements [60 points, 6 extra credit]
In this assignment you will implement three types of hash tables. Download the attached Main.java and
SymbolTable.java les. The rst le denes some tests for the symbol tables, the second is the symbol table
interface.
Write a class called TwoProbeChainHT that implements a two-probe separate chaining hashtable.
Two-probe hashing means that you will hash to two positions, and insert the key in the shorter of the
two chains. [24 points total]
Proper hash calculations. [4 points]
* For the rst hash function, use the one given in the slides: hash(k)=(k.hashCode() & 0x7f)
% M
* For the second hash function, use: hash2(k)= (((k.hashCode() & 0x7f) % M) * 31) % M
* Use Java's LinkedList class to store each chain. Do not use SequentialSearchST.
* Do not use parallel arrays.
void put(Key key, Value val) - see interface. [7 points]
Value get(Key key) - see interface. [6 points]
void delete(Key key) - see interface. [7 points]
3 Testing
The provided driver le already contains several tests for the operations in the interface. Out of the box,
the ChainHT implementation should pass these tests. Note that the tests require assertions to be enabled.
The tests are designed to check not only the interface operations in isolation, but how they interact with
each other. For example, they check that certain properties of the symbol table are invariant over the
operations. An invariant is something that does not change. Like the size of the ADT before and after
checking if an element is contained. Figure 2 shows the expected output from the driver, once the two
classes (TwoProbeChainHT, and LinearProbingHT) have been implemented. Initially, the driver won't
compile since it depends on those two classes. Be aware that while a considerable number of operations are
tested, what is provided is not comprehensive. For example, all tests use the String data type and do not
check how well the ADT functions with other types (e.g., Integer, Double, a custom class, etc).
For this assignment, there is no testing write up required. However, you may want to do your own testing
to verify the completeness of your implementation.
#Assignment #Lab #Project #SER222 #ASU #Arizona
Рекомендуемые видео



















