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
What is the difference between operating systems and application software?
mojhsa [17]

Answer:

The main difference between operating system and application software is that an operating system is a system software that works as the interface between the user and the hardware while the application software is a program that performs a specific task.

Explanation:

5 0
3 years ago
Write a program to print the value of a series of numbers from0-9 in descending order
steposvetlana [31]
This is the simplest way obviously this is ascending

print ("0")
print ("1")
print ("2")
print ("3")
print ("4")
print ("5")
print ("6")
print ("7")
print ("8")
print ("9")
6 0
3 years ago
What is the proper order for the fetch-execute cycle?
vesna_86 [32]

Control Unit – controls all parts of the computer system. It manages the four basic operations of the Fetch Execute Cycle as follows:

Fetch – gets the next program command from the computer’s memory

Decode – deciphers what the program is telling the computer to do

Execute – carries out the requested action

Store – saves the results to a Register or Memory

Arithmetic Logic Unit (ALU) – performs arithmetic and logical operations

Register – saves the most frequently used instructions and data

5 0
3 years ago
11. SQL Output III
borishaifa [10]

Answer:

wertweabcd

Explanation:

The LPAD() function left-pads a string with another string, to a certain length.

LPAD(string, length, lpad_string)

Parameter Description

string: Required. The original string. If the length of the original string is larger than the length parameter, this function removes the overfloating characters from string

length: Required. The length of the string after it has been left-padded

lpad_string: Required. The string to left-pad to string.

In example;

SELECT LPAD("SQL Brainly", 20, "ABC");

Output : ABCABCABSQL Brainly

4 0
2 years ago
What formula most likely exists in D18?
gavmur [86]
<span>Cystagia from Dynamic Nutritionals is a homeopathic UTI, bladder and kidney support that promotes urinary tract health and function.</span>
4 0
3 years ago
Other questions:
  • A ________ is a set of rules that governs data communication.
    14·1 answer
  • Effective note-taking helps support<br><br> action.<br> distinction.<br> distraction.<br> retention.
    9·2 answers
  • A single point of failure is a piece of hardware or application that is key to ________________________.
    8·1 answer
  • Public class Robot
    15·1 answer
  • What is microsoft access?
    14·1 answer
  • There are many advantages and some disadvantages to using social media. Explain at least one of the advantages to
    5·1 answer
  • __' the low level language? a.machine and assembly c.3G and 4G d.machine and 4gl​
    15·1 answer
  • Choose the item which best describes the free frame list. 1. a per process data structure of available physical memory 2. a glob
    7·1 answer
  • True or False: VLANs in cloud computing are most likely to be found on direct connections with a CSP.
    9·1 answer
  • A technician is testing a connector in a circuit with a voltmeter. With the power on in the circuit, the meter reads 12 volts wh
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!