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 inputtxt 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
delete
delete
Note:
delete
The above lines will not be in the file because delete will insert a new node since it doesnt exist and then, the on the next line will attempt to insert a second 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 outputtxt
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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
