Question: Assignment Dictionary Program Flow For this assignment we will build a digital dictionary that a user can use to look up words. The dictionary will

Assignment Dictionary

Program Flow

For this assignment we will build a digital dictionary that a user can use to look up words. The dictionary will only hold words, but no definitions. Your program should begin by greeting the user and printing out the number of words in the dictionary:

Assignment Dictionary Program Flow For this

The user should then be prompted to enter a word:

Assignment Dictionary Program Flow For this

Your program should then print out the number of comparisons made to look up the word in the dictionary. It will also print out whether the word exists or not.

Assignment Dictionary Program Flow For this

Assignment Dictionary Program Flow For this

After each word, the user should be prompted to continue playing or not. If they choose to continue, they should be able to look up other words.

Assignment Dictionary Program Flow For this

Dictionary Class

You should write a class called Dictionary that uses the following class diagrams. The class will manage a binary search tree that holds the words in a file called dictionary.txtAssignment Dictionary Program Flow For thisAssignment Dictionary Program Flow For this. The DictionaryWord class is a private-static-inner class.

Assignment Dictionary Program Flow For this

Fields:

words: this arraylist will hold all the words from a file called dictionary.txt.

root: the root of a balanced binary search tree that holds the words in a dictionary.

Methods:

loadDictionary()

This method should open the file called dictionary.txt and read each word from the file into the words array list.

buildBST()

This method builds the binary search tree of words, using the words stored in the words array list.

The binary search tree you build should be balanced. Use the following technique to accomplish this:

Write a recursive method that accepts a low and high index for your arraylist

The method will first use low and high to calculate a middle index

Add the word at the middle index to the binary search tree

Recursively pass the left and right sides of your array list back to the recursive method

Look at our binary search example as a starting point

Your base case should be when the low and high index are out of order

When initially calling your recursive method to add a new element to the binary search tree, pass 0 and words.size() 1 as your low and high index

isAWord()

This method should accept a word and traverse your binary search tree looking for the word

The method will return true, if the binary search tree contains the word, otherwise false

wordCount()

Returns the number of elements in your binary search tree

questionsAsked()

This method will return the number of comparisons it took to determine whether the last word requested by the user was in the dictionary or not.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!