Question: In java, populate a binary search tree from an input file ( input . txt ) that contains a list of numbers. The file can

In java, populate a binary search tree from an input file (input.txt) that contains a list of numbers. The file can also contain the keyword delete followed by a number. Search for a node within the tree for that number and delete it. If the number is not found, insert the node. The tree will not contain any duplicates.
Sample input.txt file
1
2
3
delete 3
5
6
delete 9
Note:
delete 8
8
The above lines will not be in the file because delete 8 will insert a new node since it doesnt exist and then, the 8 on the next line will attempt to insert a second 8, which would be a duplicate.
At the end, display the tree in preorder, inorder, and postOrder format. Also, display the tree level by level (breadth search format). The display should be redirected to a file (output.txt).
Note: When deleting, make sure to account for no children, one child and two children.

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 Programming Questions!