1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
natta225 [31]
2 years ago
11

Update thejavafile names to include your initials at the end, send .java file only.1. Completein-place heapSort, which takes an

array of data, convert it to maxheapusing bottom-up algorithm. The expected run time should be O(n), where n is the total number of data. BubbleDown method isNOTprovided, we went over a similar one in class and it’s on class website.swap method is provided and you have to write your own BubbleDown method.2. Complete the efficient quickSort. Choose the medianof three values as the pivot. Switch to insertSort if sub-problem is small. Check with sizes 3, 8, 20, choosesone that gives the best runtimeplease use code below:public class A4Sort{ public static void quickSort(int[] a, int l, int h){ if (l >= h) return; if (/*fill in */) { /*fill in */ } int pivot = partition(a, l, h); quickSort(a, l, pivot - 1); quickSort(a, pivot + 1, h); } public static int partition(int[] a, int l, int h){ int pivot = a[h]; //use last entry int last = h; h--; while (l < h){ while(a[l] < pivot) { l++; } while(a[h] > pivot){ h--; } if (l < h) swap(/*fill in */); else swap(/*fill in */); } return l; } public static void insertionSort(int[] a, int l, int h){ for (int i = /*fill in */; i++){ int j = i; int v = a[i]; while (j > 0 && v < a[j - 1]){ a[j] = a[j - 1]; j--; } a[j] = v; } } public static void swap(int[] a, int i, int j){ int temp = a[i]; a[i] = a[j]; a[j] = temp; } public static void heapSort(int[] a, int l, int h){ heapify(a); //maxheap } public static void heapify(int[] a){ /*fill in */ } public static void bubbleDown(int[] a, int i, int size){ /*fill in */ } public static void main(String[] args){ int[] a = new int[]{3,19,12,7,15,1,16,4,18,9,13,2,17,5,10,11,14,6,8,20}; int[] b = new int[]{3,19,12,7,15,1,16,4,18,9,13,2,17,5,10,11,14,6,8,20}; long time, nextTime; System.out.println("quickSort: "); time = System.nanoTime(); quickSort(a, 0, a.length - 1); nextTime = System.nanoTime(); System.out.println("\tTime used: " + (nextTime - time) + " nseconds"); for (int i = 0; i < a.length; i++) System.out.print(a[i] + ","); System.out.println(); System.out.println("heapSort: "); heapSort(b, 0, b.length - 1); for (int i = 0; i < b.length; i++) System.out.print(b[i] + ","); System.out.println(); }}
Computers and Technology
1 answer:
Sladkaya [172]2 years ago
3 0

Answer:

Yes

Explanation:

Because you send it to the java file and the java file is only one single (1)

You might be interested in
What language used orthogonality as a primary design criterion?
pogonyaev
LIPS a functional language is one in which computations are made primarily by applying function to given program
4 0
3 years ago
Assume that ip has been declared to be a pointer to int and that result has been declared to be an array of 100 elements . Assum
Bogdan [553]

Answer:

The expression of this question can be given as:

Expression:

*ip + 1

Explanation:

In this question, it is given that ip variable has been declared and initialized and the ip variable is in the first half of the array. It finds the expression whose value is after the element of the array that ip points. So the expression to this question is *ip + 1. Where * is used to define ip variable as a pointer and its value is increased by 1 that is given in the question.

7 0
3 years ago
Select the risks associated with the Internet.
tino4ka555 [31]
Sharing your personal information and identity theft but if you’re supposed to choose one then sharing your personal information must be right
3 0
2 years ago
What is Game Theory?
AleksandrR [38]

Answer:

the branch of mathematics concerned with the analysis of strategies for dealing with competitive situations where the outcome of a participant's choice of action depends critically on the actions of other participants

Explanation:

In simple terms Game theory is the study of how and why people make decisions.

8 0
2 years ago
I have a question involving do and for loops while using arrays.
larisa86 [58]

Answer:

i just got my new pc

Explanation:

5 0
2 years ago
Other questions:
  • Using the flowchart below, what value when entered for Y will generate a mathematical error and prevent our flowchart from being
    14·1 answer
  • given the numerical value 1010101.11, which of the following number systems is most likely represented.
    11·1 answer
  • Text, numbers,graphics, sounds entered into a computer's memory during input operations are referred to as
    11·1 answer
  • Your company has recently been hired to install a smart security system for a large office building. The system will include sec
    12·1 answer
  • What was the ENIAC computer and how was it used/what for?
    9·1 answer
  • What do developers do to support software products
    14·1 answer
  • Consider the following constructor for an immutable matrix ADT:
    8·1 answer
  • Is a collection of information stored under a single nam​
    6·2 answers
  • What is the name of the function below?<br><br> function go(){<br> alert("hello everybody");<br> }
    10·1 answer
  • What is a zerø-day exploit? No go.ogle &gt;:(
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!