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 03:30
Jessie has received a contract to build a real-time application for a baker. however, the baker doesn't want to invest too much money. his only requirement is that he wants the customers to know which cupcakes are available at what time and in what quantity. so his core requirement is that the details of product should be in real time. what platform can jessie use to develop this application?
Answers: 1
question
Computers and Technology, 23.06.2019 11:00
Describe three characteristics of at-risk drivers. a. b. c. describe three characteristics of safe drivers. a. b. c. describe three driver errors that could cause a collision. a. b. c. how will this information affect you as a driver now and in the future? (2-3 sentences)
Answers: 2
question
Computers and Technology, 24.06.2019 15:30
During the software planning process, rick, a project manager, finds that his team has made an incorrect estimation of funds. what kind of risk has rick identified? rick has identified a risk.
Answers: 1
question
Computers and Technology, 25.06.2019 22:20
Lenny wants to use his coworker's computer system. when he arrives at his coworker's workstation, the screen is blank. what could the issue be? the computer is not turned on. there is no internet connection. the keyboard is not functioning. the computer is in sleep mode.
Answers: 2
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
Mathematics, 12.06.2021 14:00
question
Mathematics, 12.06.2021 14:00
question
Mathematics, 12.06.2021 14:00
question
Spanish, 12.06.2021 14:00
Questions on the website: 13722359