Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Advanced Structured Programming and Algorithms

A Binary Search Tree (BST) for a set of input can have many different forms, and the structure of the tree you get depends on the sequence of data from the input array.

The tree is built by calling the treeInsert method on each of the item you encounter in the array. For example, if your input array is
A = {10, 8,2,5}

Then, you would call treeInsert(T,10), treeInsert(T, 8), treeInsert(T, 2), and treeInsert(T, 5). This should place all the elements in the proper position in the BST.

NOTE: You MUST use the pseudocodes given in the class to develop your program (i.e., No Googling and copying codes from a ready-made BST program. They might do it in some different ways).

1. Create a class called Node. This class should have the followings:
- A data member to hold a key that is an int value
- It has data members that point to parent, left, and right nodes
- A constructor that takes the key value

2. Create a binary search tree class. This class should have the followings:
- A data member that points to the root node of the tree
- A constructor that takes an int[] array as argument and build the BST from the array (each node is an object created from class Node in problem 1)
- An iterativeSearch method that can be used to search for a node with the given key value
- A insert method to insert a node into the tree
- A successor method that finds the successor for a given node
- A minimum method that finds the minimum value in any of the subtrees, given a node x (not just from the root and not just the minimum of the entire input array)
- An inorderTreeWalk method that can be used to display the results from the in-order tree walk, starting from any given node

3. Add the main method inside of the binary search tree class to test your codes. Your tests should do the followings:
- Use the input array A = {15, 6, 18, 3, 7, 17, 20, 2, 4, 12, 8}
- Build the binary search tree for this input
- Do the inorderTreeWalk to display the results (this should show the sorted list)
- Use the minimum method to find the minimum, starting from the node with key = 18
- Find the successor to the root node, and display the result on the screen
- Find the successor to node with key = 12, and display the result on the screen The output from running the program should display on the screen as follows:

Inorder tree walk: 2 3 4 6 7 8 12 15 17 18 20
Minimum from node.key = 18 is [the result] Successor to the root node is [the result] Successor to the node.key = 12 is [the result]

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M92405485
  • Price:- $20

Priced at Now at $20, Verified Solution

Have any Question?


Related Questions in Computer Engineering

Suppose you take out a loan for 5000 at 6 ordinary interest

Suppose you take out a loan for $5,000, at 6% ordinary interest. If the amount of interest is $91.67, what is the time period? (Round to next higher day)

Calculate the standard gibbs free energy change and the

Calculate the standard Gibbs free energy change and the equilibrium constant for the oxidation of a formate ion to carbon dioxide at pH=7 and room temperature.

With regards to data mining business analytics why is it

With regards to data mining/ business analytics, Why is it not ideal to evaluate a classifier's performance on the training data set?

A mixture of 499 mol of n2 and 3090 g of no is heated in a

A mixture of 4.99 mol of N2 and 30.90 g of NO is heated in a closed vessel to 2000 °C. After heating, the total pressure of the mixture at equilibrium is 3.14 atm. N2(g) + O2(g) 2NO(g) Kp= .101 at 2000 C In which directi ...

Question a add a navigation form to your applicationa

Question: A) Add a Navigation form to your application. A navigation form makes it easy for users to switch between the various forms and reports in your database. Navigation forms are a great addition to any desktop dat ...

What is the simplest way to understand hc03 in the

What is the simplest way to understand HC03 in the acid-base study of electrolytes?

What type of economic system does norway have explain some

What type of economic system does Norway have? Explain some of the benefits of this system to the country and some of the drawbacks

Sorting amp searching i need this written in cwrite a

Sorting & Searching ( I need this written in C) Write a program that will allow a user the opportunity to compare and analyze the efficiency of several sorting algorithms. The program will sort integer arrays of size 10, ...

Do you believe corporation pose as a risk to our national

Do you believe corporation pose as a risk to our national economy and to domestic employees based upon external shocks to our economy as well as government regulations and Obamacare?

Need guidance on a c program that1 asks the user to input a

Need guidance on a C++ program that: 1. Asks the user to input a number of cents 2. Calculates and displays the number of quarters, dimes, nickels, and pennies that should be used to reach the value. EX: 67 cents would b ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As