Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 Data type for the keys

* @param Data type for the values

*/

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 keys();

/**

* 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems For Advanced Applications 27th International Conference Dasfaa 2022 Virtual Event April 11 14 2022 Proceedings Part 2 Lncs 13246

Authors: Arnab Bhattacharya ,Janice Lee Mong Li ,Divyakant Agrawal ,P. Krishna Reddy ,Mukesh Mohania ,Anirban Mondal ,Vikram Goyal ,Rage Uday Kiran

1st Edition

3031001257, 978-3031001253

More Books

Students also viewed these Databases questions

Question

What are the classifications of Bank?

Answered: 1 week ago