Package org.terrier.sorting
Class HeapSort
- java.lang.Object
-
- org.terrier.sorting.HeapSort
-
public class HeapSort extends java.lang.ObjectAn implementation of the heap sort algorithm as described in Cormen et al. Introduction to Algorithms. In addition, this class may sort a part of an array in ascending order, so that the maximum N elements of the array are placed in the array's last N positions (the maximum entry of the array will be in array[array.length-1], the second maximum in array[array.length-2] etc.NB: This class is not thread-safe
- Author:
- Vassilis Plachouras
-
-
Constructor Summary
Constructors Constructor Description HeapSort()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidheapSort(double[] A, int[] B)Sorts the given array using heap-sort in ascending orderstatic voidheapSort(double[] A, int[] B, int topElements)Sorts the top topElements of the given array in ascending order using heap sort.static voidheapSort(int[] A, double[] B)Sorts the given array using heap-sort in ascending orderstatic voidheapSort(int[] A, double[] B, int topElements)Sorts the top topElements of the given array in ascending order using heap sort.
-
-
-
Method Detail
-
heapSort
public static void heapSort(double[] A, int[] B)Sorts the given array using heap-sort in ascending order- Parameters:
A- double[] the array to be sortedB- int[] another array to be sorted in ascending order of A.
-
heapSort
public static void heapSort(double[] A, int[] B, int topElements)Sorts the top topElements of the given array in ascending order using heap sort.- Parameters:
A- double[] the array to be sortedB- int[] another array to be sorted in ascending order of A.topElements- int the number of elements to be sorted.
-
heapSort
public static void heapSort(int[] A, double[] B)Sorts the given array using heap-sort in ascending order- Parameters:
A- int[] the array to be sortedB- double[] another array to be sorted in ascending order of A.
-
heapSort
public static void heapSort(int[] A, double[] B, int topElements)Sorts the top topElements of the given array in ascending order using heap sort.- Parameters:
A- int[] the array to be sortedB- double[] another array to be sorted in ascending order of A.topElements- int the number of elements to be sorted.
-
-