Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java A company wants to implement its customer registry as a binary search called CustomerBST. Write a class, called CustomerNode, to hold the following information

Java A company wants to implement its customer registry as a binary search called CustomerBST.
Write a class, called CustomerNode, to hold the following information about a customer:
id (as an int)
name (as a String)
balance (as a double)
left (a reference to the left CustomerNode object)
right (a reference to the right CustomerNode object)
Write the CustomerBST class, which is a binary search tree to hold objects of the class CustomerNode. The key in each node is the id. This class should define an instance variable root (the only instance variable of the class) and should implement the following interface CustomerIF.Write a TestCustomerBST class to test the above classes. This class should have a main method in which you perform the following actions:
Create a CustomerBST object.
Insert 40 CustomerNode objects (using a for loop) into the created BST in the following way:
customerID is a random number between 0 and 1000.
name can be a string that you randomly pick from a predefined array of strings.
balance is a random number between 1 and 10000.
Call the preorder traversal method and print out its resulting LinkedList of nodes.
Call the inorder traversal method and print out its resulting LinkedList of nodes.
Call the postorder traversal method and print out its resulting LinkedList of nodes.
Print out the number of customers that have a balance greater than 5000.
Print out the details about the customer node with the smallest customerID.
Print out the details about the customer node with the highest customerID.
image text in transcribed

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

Beginning ASP.NET 4.5 Databases

Authors: Sandeep Chanda, Damien Foggon

3rd Edition

1430243805, 978-1430243809

More Books

Students also viewed these Databases questions

Question

Why do large-lot sizes not work well with pull systems?

Answered: 1 week ago

Question

6 What is the balanced scorecard method?

Answered: 1 week ago