Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Generic Binary Search Tree Project c + + In this project you will be creating a binary search tree to store words read from the

Generic Binary Search Tree Project c++
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 sample word list 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

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

More Books

Students also viewed these Databases questions

Question

Explain the function and purpose of the Job Level Table.

Answered: 1 week ago