From bc2b524b6069a5167e0be9bd62006287614cfdc4 Mon Sep 17 00:00:00 2001 From: patel-nikhil Date: Sun, 26 Jan 2020 01:39:34 -0500 Subject: [PATCH 1/2] Reordered sortHeap method --- HeapSort.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/HeapSort.java b/HeapSort.java index e7da94b..ee909cf 100644 --- a/HeapSort.java +++ b/HeapSort.java @@ -8,24 +8,25 @@ * */ public class Heap { + /** * heap sort (case-insensitive) * @param x array of subjects * @param y associated array * @param n problem size */ - public static void sortHeap (String[] x, String[] y, int n ) { + public static void sortHeap (String[] x, Integer[] y, int n ) { this.construct(x,y,n); this.sort(x,y,n); } - + /** * heap sort (case-insensitive) * @param x array of subjects * @param y associated array * @param n problem size */ - public static void sortHeap (String[] x, Integer[] y, int n ) { + public static void sortHeap (String[] x, String[] y, int n ) { this.construct(x,y,n); this.sort(x,y,n); } From 1397f42de537069bb7f2370eab5789d43a90729b Mon Sep 17 00:00:00 2001 From: patel-nikhil Date: Mon, 27 Jan 2020 22:07:03 -0500 Subject: [PATCH 2/2] Comment change only --- HeapSort.java | 7 ------- 1 file changed, 7 deletions(-) diff --git a/HeapSort.java b/HeapSort.java index ee909cf..e584ba2 100644 --- a/HeapSort.java +++ b/HeapSort.java @@ -123,12 +123,6 @@ private static void sort(String[] x, String[] y, int n){ } } - /** - * Performs sortdown of a max-oriented heap to produce a sorted array - * @param x input array organized as max-oriented heap - * @param y associated array - * @param n size of input array - */ private static void sort(String[] x, Integer[] y, int n){ int end = n - 1; @@ -138,7 +132,6 @@ private static void sort(String[] x, Integer[] y, int n){ exchange(x, y, 0, end); - //fix heap order by checking root node with child nodes and switching where necessary int i = 0; while (2*i+1 < end && 2*i+2 < end && ((lower(x[2*i+1]).compareTo(lower(x[i])) > 0) || (lower(x[2*i+2]).compareTo(lower(x[i])) > 0))){ //If at least one of the children is non-null and bigger