Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question

1. Create a Java program that prompts the user the initial choices for the Binary Search Tree
a. User chooses

1: Insert, User chooses

2: Delete, User chooses

3: Show Binary
Tree, User chooses

4: Exit Program 

2. Insertion in a tree should be such that it obeys the main properties of the binary search
tree. The basic algorithm should be:
a. If the node to be inserted is greater than the existing root, move down a level
through the right pointer of the root.
b. If the node to be inserted is lesser than the existing root, move down a level
through the left pointer of the root.
c. Repeat this process for all nodes till the leaves are reached.
d. Insert the node as the left or right pointer for the leaf (based on its value - if it is
smaller than the leaf, it should be inserted as the left pointer; if it is larger than the
leaf, it should be inserted as the right pointer) 

3. Deletion is a bit more complicated than insertion because it varies depending on the node
that needs to be deleted from the tree.
a. If the node has no children (that is, it is a leaf) - it can simply be deleted from the
tree.
b. If the node has one child, simply delete the node and move the child up to replace
it.
c. If the node has two children, it becomes a little tricky. We need to find the node
which has the smallest value in the right subtree (among the elements that have a
greater value than the node to be deleted) for the node and use that to replace the
deleted node. (Note that the smallest value in the right subtree is the node that
comes immediately after the node to be deleted, implying that it is the inorder
successor for the node to be deleted).

If the user chooses to delete an element from the Binary Search Tree:
a. Display the elements in the binary tree
b. Prompt the user to enter an element to be deleted.
c. After entering a number to be deleted, show the updated elements contained in
the binary tree. 

 

Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Computer Science
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.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education