Terrier IR Platform
2.2.1

uk.ac.gla.terrier.utility
Class HeapSort

java.lang.Object
  extended by uk.ac.gla.terrier.utility.HeapSort

public class HeapSort
extends java.lang.Object

An implementation of the heap sort algorithm as described in Cormen et al. Introduction to Algorithms. This class sorts two arrays, with respect to the values of the elements in the first array. There is also an option to sort only N entries with the highest values. In this case, there are two options:

Version:
$Revision: 1.12 $
Author:
Vassilis Plachouras

Constructor Summary
HeapSort()
           
 
Method Summary
static void ascendingHeapSort(double[] A, int[] B, short[] C)
          Sorts the given arrays in ascending order, using heap-sort.
static void ascendingHeapSort(double[] A, int[] B, short[] C, int topElements)
          Sorts the top topElements of the given array in ascending order, using heap sort.
static void descendingHeapSort(double[] A, int[] B, short[] C)
          Sorts the given arrays in descending order, using heap-sort.
static void descendingHeapSort(double[] A, int[] B, short[] C, int topElements)
          Sorts the top topElements of the given array in descending order, using heap sort for sorting the values in ascending order and then reversing the order of a specified number of elements.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HeapSort

public HeapSort()
Method Detail

ascendingHeapSort

public static void ascendingHeapSort(double[] A,
                                     int[] B,
                                     short[] C)
Sorts the given arrays in ascending order, using heap-sort.

Parameters:
A - double[] the first array to be sorted.
B - int[] the second array to be sorted, according to the values of the first array.

descendingHeapSort

public static void descendingHeapSort(double[] A,
                                      int[] B,
                                      short[] C)
Sorts the given arrays in descending order, using heap-sort.

Parameters:
A - double[] the first array to be sorted.
B - int[] the second array to be sorted, according to the values of the first array.

ascendingHeapSort

public static void ascendingHeapSort(double[] A,
                                     int[] B,
                                     short[] C,
                                     int topElements)
Sorts the top topElements of the given array in ascending order, using heap sort.

Parameters:
A - double[] the first array to be sorted.
B - int[] the second array to be sorted, according to the values of the first array.
topElements - int the number of elements to be sorted.

descendingHeapSort

public static void descendingHeapSort(double[] A,
                                      int[] B,
                                      short[] C,
                                      int topElements)
Sorts the top topElements of the given array in descending order, using heap sort for sorting the values in ascending order and then reversing the order of a specified number of elements.

Parameters:
A - double[] the first array to be sorted.
B - int[] the second array to be sorted, according to the values of the first array.
topElements - int the number of elements to be sorted.

Terrier IR Platform
2.2.1

Terrier Information Retrieval Platform 2.2.1. Copyright 2004-2008 University of Glasgow