Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The goal of this assignment is to work with the implementation of a Binary Search Tree (BST) given in the textbook, Chapter 25. Then, write

The goal of this assignment is to work with the implementation of a Binary Search Tree (BST) given in the textbook, Chapter 25. Then, write simple program to take a text input (from the keyboard or a text file) and remove all duplicate words from the input text.

The program must allow the user to select the input method (keyboard or text file) using a simple menu such as:

-----MAIN MENU-----

0 - Exit Program

1 - Read Input From Text File

2 - Read Input Form Keyboard

As in previous assignments, the code starts by displaying the menu for the user initial interaction. Make sure you re-display the menu after each option is completed, by embedding the menu inside a sentinel loop. Please DO NOT hard-code test data. Please make sure to use meaningful labels for outputs and clear prompts for inputs.

Part 1: (25 points)

Type and compile the following files from chapter 25: Tree.java, AbstractTree.java, and BST.java.

Next, type, compile, and run the following programs from chapter 25: TestBST.java and TestBSTDelet.java. Note that you may need to include class TreeNode.java. Code may vary among different versions of the textbook. Do NOT start part 2 until all programs in this part are working properly (save all files in one folder).

Part 2: (75 points)

Following the test programs in part 1 above, write new test program called RemoveDuplicates.java. The program reads text input from either the keyboard or a text file (see menu-based design above) and adds the words (not characters) to a BST. The program then traverses the BST and prints out the words in order (based on ASCII/UNICODE order) on the screen or to output text file, based on the selected menu option. Again, you may need to make some changes to BST.java as code may vary among different versions of the textbook.

Sample test using keyboard input:

----jGRASP exec: java -ea removeDuplicates

Original Text:

a B 2 n w C q K l 0 M a M l a B 2 n w 9

Processed Text:

0 2 9 B C K M a l n q w

----jGRASP: operation complete.

Sample test using keyboard input:

----jGRASP exec: java -ea RemoveDuplicates

Original Text:

this is a test for the test in the program that does no test

Processed Text: a does for in is no program test that the this

----jGRASP: operation complete.

Sample test using input text file:

----jGRASP exec: java -ea removeDuplicates

Original Text from input file:

Following the test programs above, write new test program called RemoveDuplicates.java. The program reads text input from keyboard or a text file and adds the words to a BST. The program then traverses the BST and prints out the words in order on the screen (or to output text file). Note that you may need to make some changes to BST.java.

Processed text is saved to output file.

----jGRASP: operation complete.

The content of the output file is as follows:

(or BST BST. BST.java. Following Note RemoveDuplicates.java. The a above, adds and called changes file file). from in input keyboard make may need new on or order out output prints program programs reads screen some test text that the then to traverses words write you

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

Students also viewed these Programming questions