Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

for JAVA Problem 1: In this problem you will implement a Binary Search Tree. The tree will be storing students information which you will insert

for JAVA
image text in transcribed
image text in transcribed
Problem 1: In this problem you will implement a Binary Search Tree. The tree will be storing students information which you will insert and delete. You will also implement the inorder() tree traversal. In addition, you will implement findKthSmallest() which finds the kth smallest node key. Implement the following classes: 1. class Node that includes: Three instance variables: private int ID; private double GPA; private Node Left; private Node Right. A constructor that initializes the two instance variables ID and GPA. Set and get methods for each instance variable. .toString method that returns a string containing the student id, GPA). 2. class BSTree that includes: private Node Root. public boolean exist(int id) private boolean exist(Node s, int id) that checks whether a node with the same id exists in the BST Tree or not. public boolean insert(int id, double gpa) private void insert(Node R, Node 5) that inserts a new node into the binary tree. If the student ID already exists the method will return false, otherwise it will return true after inserting. public boolean remove(int ID)that removes the student with the specified ID. If the student doesn't exist the method will return false, otherwise it will return true. public void inder() private void inOrder (Node R) That traverses and prints the contents of the tree in-order according to the ID. (From least to highest ID). public int kthSmallest(Node root, int k) that returns the kth smallest node key. 3. Write a test application named TestBST. In the main method, do the following: Create a BSTree object. Display a menu to the user and asking for a choice to be entered. As follows: The program can perform the following: 1- Insert Students 2- Remove a Student 3- Check if a Student Exists 4- Print InOrder 5- Find kthSmallest 6- Exit Please enter your selection: The program will perform the action selected by the user and display a proper message when necessary. The program will repeat these actions until the user terminates the program

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

Database Driven Web Sites

Authors: Joline Morrison, Mike Morrison

2nd Edition

? 061906448X, 978-0619064488

More Books

Students also viewed these Databases questions

Question

Why do HCMSs exist? Do they change over time?

Answered: 1 week ago