Question: Generic Binary Search Tree Project In this project you will be creating a binary search tree to store words read from the file specified on

Generic Binary Search Tree Project

In this project you will be creating a binary search tree to store words read from the file specified on the command line, and displaying the contents of the tree in pre- in- and post- order traversals.

Requirements:

If the command line doesnt have 1 argument, an error message should be displayed.

Open the file specified in the command line argument, verify the file opened successfully, if the file fails to open, an error message should be displayed.

Read in the entire file (the code can assume there will only be one word on each line)

As each word is read, add it to a binary search tree

After reaching the end of the file, do a pre-order traversal of the tree, printing out the word stored in each node

Then do an in-order traversal of the tree, again displaying the words as each node is visited. The words should be displayed in alphabetical order.

Ask the user to search for a word or q to quit. Tell the user if the corresponding word is in the binary tree.

After the user selects q to quit, delete all the tree nodes by using a post-order recursive traversal, printing the string stored in the node before it is deleted.

Implementation suggestions:

Use ifstream::open to open the file specified on the command line

Use ifstream::is_open to verify the file opened correctly

Use getline(ifstream, str) function to read a line of text

Use ifstream::eof() to determine when the end of file is reached

wordlist.txt

hapless immerse stretch oatmeal occur eyes direct weather abrasive boundless sloppy uproot thankful injure forgive bun adorable bit faucet absent acidic party contrast woebegone vacation vary puny hard-to-find heavenly body hearing aberrant produce insert next peace frantic aggressive summon needless

Be sure to read the project description carefully: String Binary Search TreeLinks to an external site.

Links to an external site.

Here is a sample word list file: wordlist.txtLinks to an external site.

And a sample output fileLinks to an external site.. Please try to get your program's output to match this output.

Rubric

Generic Binary Search Trees

Generic Binary Search Trees

Criteria Ratings Pts

This criterion is linked to a Learning OutcomeVerify the cmd line argument specifies a valid file by opening and reading from the file. If there is an problem, display an appropriate error message

5 pts

This criterion is linked to a Learning OutcomeCorrectly read in word list file and create binary search tree to storing all the words in the file

10 pts

This criterion is linked to a Learning OutcomeCorrectly display the words in the binary search tree by doing an "pre-order" traversal

10 pts

This criterion is linked to a Learning OutcomeCorrectly display the words in the binary search tree by doing an "in-order" traversal

10 pts

This criterion is linked to a Learning OutcomeCorrect use of postorder traversal to free all nodes after tree object is deleted and displaying the node's word before it's deleted.

10 pts

This criterion is linked to a Learning OutcomeEfficient coding style, good use of identifier names, commenting

5 pts

This criterion is linked to a Learning OutcomeCan correctly search for words in the binary tree

10 pts

Total Points: 60

second files :

***** PreOrder: ***** hapless eyes direct abrasive aberrant boundless adorable absent acidic bit aggressive body bun contrast forgive faucet frantic immerse hard-to-find heavenly hearing stretch oatmeal injure insert next needless occur sloppy party puny produce peace weather uproot thankful summon vacation vary woebegone

***** InOrder: ***** aberrant abrasive absent acidic adorable aggressive bit body boundless bun contrast direct eyes faucet forgive frantic hapless hard-to-find hearing heavenly immerse injure insert needless next oatmeal occur party peace produce puny sloppy stretch summon thankful uproot vacation vary weather woebegone Enter word to search for, or 'q' to quit --> occur occur is in the tree Enter word to search for, or 'q' to quit --> head head is not in the tree Enter word to search for, or 'q' to quit --> eyes eyes is in the tree Enter word to search for, or 'q' to quit --> hapless hapless is in the tree Enter word to search for, or 'q' to quit --> weather weather is in the tree Enter word to search for, or 'q' to quit --> q Deleting node with value: aberrant Deleting node with value: acidic Deleting node with value: absent Deleting node with value: aggressive Deleting node with value: body Deleting node with value: bit Deleting node with value: adorable Deleting node with value: contrast Deleting node with value: bun Deleting node with value: boundless Deleting node with value: abrasive Deleting node with value: direct Deleting node with value: faucet Deleting node with value: frantic Deleting node with value: forgive Deleting node with value: eyes Deleting node with value: hearing Deleting node with value: heavenly Deleting node with value: hard-to-find Deleting node with value: needless Deleting node with value: next Deleting node with value: insert Deleting node with value: injure Deleting node with value: peace Deleting node with value: produce Deleting node with value: puny Deleting node with value: party Deleting node with value: sloppy Deleting node with value: occur Deleting node with value: oatmeal Deleting node with value: summon Deleting node with value: thankful Deleting node with value: vary Deleting node with value: vacation Deleting node with value: uproot Deleting node with value: woebegone Deleting node with value: weather Deleting node with value: stretch Deleting node with value: immerse Deleting node with value: hapless I do not need explaining just I need all code for c++ Thanks

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!