Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in java language . . . Q1. Implement a Binary Search Tree (BST) that stores student information. Each tree node stores: student ID as the

in java language

image text in transcribed

. . . Q1. Implement a Binary Search Tree (BST) that stores student information. Each tree node stores: student ID as the key, and student name as the value. Your BST class should have root and size as instance variables. It should also have the following methods: Insert(int key): insert the key value at the correct position and increase the size by 1 Delete(int key): delete the key and decrees the size by 1 Search(int key): search and return the value (student name) associated with the key Preorder(): print preorder traversal of the tree Postorder(): print postorder traversal of the tree printID (): this method takes a name as an argument and returns the student ID (the key). Note that this is not a typical BST operation. You can add more parameters to the method header if needed. findKthsmall(int k): this method finds and returns the kth smallest key. If the tree has less than k elements, the method returns - 1. You can add instance variables to the BST class if needed. You can also pass whatever parameters you need for your method to work. (Hint: ren er inorder traversal gives us the keys in an ascending order, hence, if I want the 3rd smallest element, then the method should return the third number of the inorder traversal list]. . The first three methods operate exactly the same as the methods we discussed in the class. Write a test class (Driver class) and show all the previous operations in action

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_2

Step: 3

blur-text-image_3

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2018 Dublin Ireland September 10 14 2018 Proceedings Part 1 Lnai 11051

Authors: Michele Berlingerio ,Francesco Bonchi ,Thomas Gartner ,Neil Hurley ,Georgiana Ifrim

1st Edition

3030109240, 978-3030109240

More Books

Students also viewed these Databases questions

Question

What is the environment we are trying to create?

Answered: 1 week ago

Question

How would we like to see ourselves?

Answered: 1 week ago

Question

How can we visually describe our goals?

Answered: 1 week ago