Answered step by step
Verified Expert Solution
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 CustomerNode objects using a for loop into the created BST in the following way:
customerID is a random number between and
name can be a string that you randomly pick from a predefined array of strings.
balance is a random number between and
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
Print out the details about the customer node with the smallest customerID.
Print out the details about the customer node with the highest customerID.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started