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]
3 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]3 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
Computer programming 3
AfilCa [17]
The first photo of output i still need 2 posts

5 0
3 years ago
Write a algorithm to attend birthday party​
kolezko [41]

Answer:

2     No

5 14    Yes

Explanation:

8 0
3 years ago
Read 2 more answers
What is a computer modem?​
ahrayia [7]

Answer:

A modem modulates and demodulates electrical signals sent through phone lines, coaxial cables, or other types of wiring.

8 0
2 years ago
Any software or program that comes in many forms and is designed to disrupt the normal operation of a computer by allowing an un
Paha777 [63]
<span>Any software or program that comes in many forms and is designed to disrupt the normal operation of a computer by allowing an unauthorized process to occur or by granting unauthorized access is known as: Malicious code
Malicious code is often created to steal some information from another user without they realizing it, such as address, credit card number, social security number, email password, etc.</span>
4 0
3 years ago
Ternary operators of computer<br><br>please explain. ​
Nitella [24]

Answer:

It's a compact way of doing an if-else statement.

General Format is

<<em>condition</em>> ? <if condition is true> : <else>;

Example:

I could rewrite:

  if(a==1) temp = 1;

  else     temp = 999;

as

  temp = (a==1) ? 1 : 999;

5 0
3 years ago
Other questions:
  • Write a function decimalToBinaryRecursive that converts a decimal value to binary using recursion. This function takes a single
    11·1 answer
  • ----------HELP WITH 3 QUESTIONS FOR 30 POINTS!!!---------
    6·1 answer
  • To what extent can u justify that computer is not the only ICT tool?​
    9·1 answer
  • Today encoding scheme has taken over ascII by what
    5·1 answer
  • When activated, an Excel object has all the features of an Excel
    8·2 answers
  • Is it possible to make teleportation with a fusion device
    15·1 answer
  • The merge sort algorithm sorts using what technique?
    8·1 answer
  • Given the three thread states: running, runnable (i.e., ready), and blocked (i.e., waiting), state which of the six possible thr
    13·1 answer
  • Why was the Internet first developed? Use details and information to explain your answer.
    6·1 answer
  • Computer always produces wrong output true or false<br>​
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!