Question: In each function in minHeap and maxHeap, there is a label called your code goes here. If you can implement all the functions in
In each function in minHeap and maxHeap, there is a label called " your code goes here". If you can implement all the functions in minHeap and maxHeap thanks. Java Please. Thank you import java.util.Scanner; public class median{ static minHeap min; static maxHeap max; public median(){ min = new minHeap(); max = new maxHeap(); } public static int calculateMedian(int x){ //your code goes here return -1; } public static void main(String[] args){ median m = new median(); System.out.println("Enter a list of non negative integers. To end enter a negative integers."); Scanner s = new Scanner(System.in); int current = s.nextInt(); while(current >=0){ System.out.println("current median:" + m.calculateMedian(current)); current = s.nextInt(); if(current<0)break; m.calculateMedian(current); current = s.nextInt(); } } } class minHeap{ private int[] heap; private int size; public minHeap(){ heap=new int[10000]; size=0; } public boolean isEmpty(){ return (size==0); } public int size(){ return size; } public void insert(int x){ //Your code goes here } public void bubbleup(int k){ //Your code goes here } public void exchange(int i,int j){ //Your code goes here } public void bubbledown(int k){ //Your code goes here } public int peek(){ //Your code goes here return -1; } public int removeMin(){ //Your code goes here return -1; } } class maxHeap{ private int[] heap; private int size; public maxHeap(){ heap=new int[10000]; size=0; } public boolean isEmpty(){ return (size==0); } public int size(){ return size; } public void insert(int x){ //Your code goes here } public void bubbleup(int k){ //Your code goes here } public void exchange(int i,int j){ //Your code goes here } public void bubbledown(int k){ //Your code goes here } public int peek(){ //Your code goes here return -1; } public int removeMax(){ //Your code goes here return -1; } }
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
