subject

The problem is to implement a convert method to convert a given Max Heap into a Binary Search Tree (BST) with the condition that the output BST needs to be also a Complete Binary Tree.

Note that we assume:

- The number of elements in the Max Heap tree is always 2^L - 1 , which L is the number of levels in the tree.

- There is no duplicate element in the Max Heap.

- The Max Heap class has add and remove methods to construct and access the elements in the Heap.

- The MyBST class has insert method.

- The Solution class contains the header of the convert method. It needs a MaxHeap and a MyBST to convert the Max Heap to a Complete BST.

- The Driver class, will construct the MaxHeap and an empty BST and pass it to the convert method.

Example:

Input to convert method (a Max Heap):

7
/ \
6 5
/ \ / \
3 4 1 2

Convert Method Output (BST):

4
/ \
2 6
/ \ / \
1 3 5 7

class Solution{
public static void convert(MaxHeap maxHeap, MyBST bst){
// Write your code here, you can add more methods

}
}

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 05:10
Read the code below. what will the computer print if the input for year_variable is 1700? if year_variable == 1776: print("your answer is correct. the declaration of independence was signed in “year_variable”.") elif year_variable < 1776: compute_variable = 1776 - year_variable. print("add “compute_variable“ years to your answer for the correct answer.") elif year_variable > 1776: compute_variable = year_variable - 1776 print("subtract “compute_variable” years from your answer for the correct answer.")
Answers: 1
question
Computers and Technology, 22.06.2019 09:50
What is a rush associated with alcohol?
Answers: 1
question
Computers and Technology, 22.06.2019 19:30
When creating a presentation in libre office impress, where does the editing of slides take place? a. the slides panel b. the center panel c. the tasks panel, under the masters pages tab d. the tasks panel, under the layouts tab
Answers: 1
question
Computers and Technology, 23.06.2019 12:30
What is the difference between the internet and the world wide web?
Answers: 1
You know the right answer?
The problem is to implement a convert method to convert a given Max Heap into a Binary Search Tree (...
Questions
question
Social Studies, 13.04.2021 17:40
question
Chemistry, 13.04.2021 17:40
question
Mathematics, 13.04.2021 17:40
question
History, 13.04.2021 17:40
question
Social Studies, 13.04.2021 17:50
Questions on the website: 13722360