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

Does bmw have a guided missile corporate culture and

Does BMW have a guided missile corporate culture, and incubator corporate culture, a family corporate culture, or an Eiffel tower corporate culture?

Rebecca borrows 10000 at 18 compounded annually she pays

Rebecca borrows $10,000 at 18% compounded annually. She pays off the loan over a 5-year period with annual payments, starting at year 1. Each successive payment is $700 greater than the previous payment. (a) How much was ...

Jeff decides to start saving some money from this upcoming

Jeff decides to start saving some money from this upcoming month onwards. He decides to save only $500 at first, but each month he will increase the amount invested by $100. He will do it for 60 months (including the fir ...

Suppose you make 30 annual investments in a fund that pays

Suppose you make 30 annual investments in a fund that pays 6% compounded annually. If your first deposit is $7,500 and each successive deposit is 6% greater than the preceding deposit, how much will be in the fund immedi ...

Question -under what circumstances is it ethical if ever to

Question :- Under what circumstances is it ethical, if ever, to use consumer information in marketing research? Explain why you consider it ethical or unethical.

What are the differences between four types of economics

What are the differences between four types of economics evaluations and their differences with other two (budget impact analysis (BIA) and cost of illness (COI) studies)?

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,

Among the who imf and wto which of these governmental

Among the WHO, IMF, and WTO, which of these governmental institutions do you feel has most profoundly shaped healthcare outcomes in low-income countries and why? Please support your reasons with examples and research/doc ...

A real estate developer will build two different types of

A real estate developer will build two different types of apartments in a residential area: one- bedroom apartments and two-bedroom apartments. In addition, the developer will build either a swimming pool or a tennis cou ...

Question what some of the reasons that evolutionary models

Question : What some of the reasons that evolutionary models are considered by many to be the best approach to software development. The response must be typed, single spaced, must be in times new roman font (size 12) an ...

  • 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