Question: BONUS (15 pts): Implement a BSTNode and BST class template. Think about: how do you accommodate two different types in a class template? please do

BONUS (15 pts): Implement a BSTNode and BST class template. Think about: how do you accommodate two different types in a class template?

please do the following in c++

1. (15 pts) Defining the BSTNode structure

For the first part of the assignment, you should start by designing the BSTNode class for the BST. Create a class for the BSTNode data that will have as its members a character and a string. The character will hold the English text character, and the string will hold the corresponding Morse code characters for that English text character. You should also define left and right child pointers that point to BSTNode objects. You must have a constructor that accepts arguments to set the English text character and Morse code string.

2. (50 pts) Create the BST code and create a Morse lookup BST

Next, you should be able to read in the Morse table from a file called MorseTable.txt. You should rearrange the Morse table in the file to make sure that your lookup tree is balanced. I recommend that you diagram a tree that provides a balanced tree so that you know how to order your MorseTable.txt file. Think about the order of insertions. However, the tree does not have to balance itself.

The tree should be built by the constructor for the BST. This means the constructor must open and read the file, create nodes for each character in the tree, insert the nodes into the tree (using an insert () function), and close the file. Note: the tree object could be declared as const, since all changes to it are being performed in the constructor. However, if you declare your object as a const, be sure to also declare your print () and search () functions as const. You should arrange the tree so that it is alphabetically ordered from left to right. Create a print ( ) function that uses recursion to traverse the tree in order (left most printed first). Also, build a search ( ) function that will return the Morse code string for each English character searched for. Do you need to return a found indicator from the search function? Should you use recursion? Finally, implement a destructor, which destroys the entire tree.

Morse Code Alphabet:

A .-

B -...

C -.-.

D -..

E .

F ..-.

G --.

H ....

I ..

J .---

K -.-

L .-..

M --

N -.

O ---

P .--.

Q --.-

R .-.

S ...

T -

U ..-

V ...-

W .--

X -..-

Y -.--

Z --..

0 -----

1 .----

2 ..---

3 ...--

4 ....-

5 .....

6 -....

7 --...

8 ---..

9 ----.

FULLSTOP .-.-.-

Comma , --..--

Query ? ..--..

3. (30 pts) Putting the pieces together

First, print the current tree. Next, you must open a file called Convert.txt, which consists of English alphabetic characters, spaces, commas, and periods. You must look for each English character with a search ( ) function on the BST, and print the Morse code string for that character. For each character in Convert.txt, convert the character to a Morse code string. Each Morse character in the string will be separated by a space. Each complete Morse string will be separated by three spaces. Each newline character will be echoed to the screen. Note: you should convert any lowercase English characters to uppercase before processing the English text.

Below is an example test file (you should add more characters to test all conversions!):

(Convert.txt)

This is a test of the cpts 122

Morse code conversion tool.

(Echoed to screen)

- .... .. ... .. ... .- - . ... - --- ..-. - .... . -.-. .--. - ... .---- ..--- ..---

-- --- .-. ... . -.-. --- -.. . -.-. --- -. ...- . .-. ... .. --- -. - --- --- .-.. .-.-.-

BONUS (15 pts): Implement a BSTNode and BST class template. Think about: how do you accommodate two different types in a class template?

IV. Submitting Assignments:

Using the OSBLE+ MS VS plugin, please submit your solution. Please visit http://osble.codeplex.com/wikipage?title=Submitting%20an%20Assignment&referringTitle=VS%20Plugin for more information about submitting using OSBLE+.

Your project must contain at least one header file (.h files) and two C++ source files (which must be .cpp files).

Your project must build properly. The most points an assignment can receive if it does not build properly is 65 out of 100.

V. Grading Guidelines:

This assignment is worth 100 points. Your assignment will be evaluated based on a successful compilation and adherence to the program requirements. We will grade according to the following criteria:

5 pts Appropriate top-down design, style, and commenting according to class standards

15 pts - Defining the BSTNode structure

4 pts correct data members in node (char, string, left and right pointers)

3 pts correct constructor

8 pts other member functions

50 pts - Creating the BST code and create a Morse lookup BST

2 pts correct data member in BST (root)

10 pts correct insert ()

2 pts for opening MorseTable.txt

2 pts for closing MorseTable.txt

6 pts for reading contents of MorseTable.txt

5 pts for correct print ()

9 pts for correct search ()

6 pts for correct constructor

8 pts for correct destructor

30 pts -Putting the pieces together

5 pts for printing the tree

2 pts for opening Convert.txt

2 pts for closing Convert.txt

6 pts for reading contents of Convert.txt

10 pts for performing conversion of English to Morse code

5 pts for echoing Morse code to screen

BONUS 15 pts Working BSTNode and BST class template

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!