Question
Task: I use java and Eclipse IDE. Thank You. Step 1: Create a binary search tree implementation of a Dictionary. The class must be named
Task:
I use java and Eclipse IDE. Thank You.
Step 1:
Create a binary search tree implementation of a Dictionary. The class must be named BSTDictionary where Dictionary is defined as:
/**
* An abstract data type for a Dictionary that maps a set of keys to values.
*
*
* @param
* @param
*/
interface Dictionary
/**
* Put a key together with its associated value into the dictionary.
* If the key already exists then the new value replaces the current
* value associated with the key. Values can be retrieved using the
* get method.
*
* @param key the key
* @param value the new value
* @return the original value if the key already exists in the
* dictionary, otherwise null.
*/
public V put(K key, V value);
/**
* Get the current value associated with a given key.
*
* @param key the key
* @return the current value associated with the key in the dictionary
* if found, otherwise null.
*/
public V get(K key);
/**
* Remove the key and its associated value associated from the
* dictionary. The value associated with the key is returned. If the
* key does not exist in the dictionary then null is returned.
*
* @param key the key
* @return the value associated with the removed key in the dictionary.
* If the key did not exist then null.
*/
public V remove(K key);
/**
* Create an Iterator to iterate over the keys of the dictionary.
*
* @return an Iterator to iterator over the keys.
*/
public Iterator
/**
* Test if the dictionary is empty
*
* @return true if the dictionary is empty, otherwise false
*/
public boolean isEmpty();
/**
* Get the number of keys in the dictionary
*
* @return the number of keys in the dictionary
*/
public int noKeys();
}
Your implementation of BSTDictionary must not use an inner/nested class of Nodes. Instead define your BSTDictionary to have a left and right instance variables that are each a BSTDictionary. This approach is going to be analogous to the Ls implementation of a linked list. When a BSTDictionary is created, it will be empty and its left and right instance variables must be null. The empty BSTDictionary is similar in purpose to the empty Ls at the end of an Ls list. On adding a key and value to an empty BSTDictionary, set the key and value instance variables accordingly and create an empty BSTDictionary for the left and create an empty BSTDictionary for the right. Note that each BSTDictionary must keep track of the number of keys in the given BSTDictionary including all descendants. Given this an empty BSTDictionary will have zero for the number of keys.
Note that keys() returns a Java Iterator, however you only need to implement the hasNext() and next() methods.
Step 3:
Create a jUnit test program to thoroughly test your BSTDictionary.
Step 4:
Create a word count program (not in edu.www.xxxx000.util). The word count program must open a text file passed to it on the command line. Your program must process the text file identifying the set of unique words in the file and the number of occurrences of each word. Separate words on spaces, commas, tabs, newlines, carriage returns, and other not alphanumeric characters (i.e. split on "\\W+").
After processing all the words in the input text file, your word count program must print a list of all the found words, in sorted order, together with the number of times each word was found within the file. The output is to be is sorted word order.
Other requirements:
1)The iterator must return the keys in an in order traversal. The iterator implementation must not copy keys into a data structure holding all keys.
2)The Dictionary and BSTDictionary must be defined in package edu.www.xxxx000.util.
3)The word count program must be defined in package edu.www.xxxx000.wordcount
4)Must provide JavaDoc
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started