Computer Science In java Output should look like this:   PreOrder: 1 2 5 6 9 InOrder: 1 2 5 6 9 Postorder: 9 6 5 2 1 BreadthFirst: 1 2 5 6 9

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Computer Science

In java

Output should look like this:

 

PreOrder:

1 2 5 6 9

InOrder:

1 2 5 6 9

Postorder:

9 6 5 2 1

BreadthFirst:

1 2 5 6 9

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
1238568
delete 3
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 doesn't 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.
Transcribed Image Text: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 1238568 delete 3 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 doesn't 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.
Expert Solution
steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Knowledge Booster
Top down approach design
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education