/** * reorder.h * A declaration of a variant of the infamous partition function * from Quicksort. */ #ifndef __REORDER_H__ #define __REORDER_H__ /** * Procedure: * reorder * Parameters: * a, an array * size, an integer * splitter, an integer * Purpose: * Rearrange a so that all the values less than or equal to splitter * fall at the left side of the array and all of the values greater than * splitter fall at the right side of the array. * Produces: * border, an integer * Preconditions: * 0 < size <= length of a * Postconditions: * Values have neither been added to no removed from a. (That is, * the resulting array is a permutation of the original array.) * There are border values in a that are <= splitter. * 0 <= border <= size. * For 0 <= i < border, a[i] <= splitter. * For border <= i <= size, a[i] > splitter. */ int reorder (int a[], int size, int splitter); #endif // __REORDER_H__