cs146/05-labHeapSort/Assignment.java

43 lines
1.0 KiB
Java

package labHeapSort;
import java.io.*;
import java.util.*;
public class Assignment {
public static int[] heapify(int[] heap, int sizeA, int index) {
// Fill in here
return heap;
}
public static int[] buildHeap(int[] arr, int sizeA) {
// Fill in here
return heapify(arr, sizeA, 1);
}
public static int[] heapSort(int[] arr, int sizeA) {
// Fill in here
return buildHeap(arr, sizeA);
}
public static void run(String inputPath) {
try (BufferedReader br = new BufferedReader(new FileReader(inputPath))) {
int size = Integer.parseInt(br.readLine());
int[] A = new int[size];
for (int i = 0; i < size; i++) {
A[i] = Integer.parseInt(br.readLine());
}
int[] heap = heapSort(A, size);
for (int i = 0; i < size; i++) {
System.out.print(heap[i] + ";");
}
System.out.println();
} catch (IOException e) {
e.printStackTrace();
}
}
}