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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 05:30, donmak3833
Agood flowchart alludes to both the inputs and outputs you will need to receive and give to the user. true or false?
Answers: 3
image
Computers and Technology, 22.06.2019 15:30, gudon986732
When creating a budget, log fixed expenses before income. after income. after savings. at the top.
Answers: 1
image
Computers and Technology, 23.06.2019 13:30, mads000
Drag the tiles to the correct boxes to complete the pairs. match the errors with their definitions. #name #value #ref when a formula produces output that is too lengthy to fit in the spreadsheet cell arrowright when you enter an invalid cell reference in a formula arrowright when you type text in cells that accept numeric data arrowright when you type in a cell reference that doesn’t exist arrowright reset next
Answers: 1
image
Computers and Technology, 23.06.2019 14:30, ladawnrowles005
The option enables you to modify a slide element in most presentation applications.
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 in other subjects:

Konu
Social Studies, 04.10.2019 23:00
Konu
English, 04.10.2019 23:00