Sorting/PointerBased/pivotMedianOfThree.c File Reference

Code to select random index as pivot index from array of strings

Given array vals[left,right] of strings, select random index within this range to use for partition. More...

#include <string.h>

Functions

int selectPivotIndex (void **vals, int left, int right)
 Code to select a pivot index around which to partition ar[left, right].


Detailed Description

Code to select random index as pivot index from array of strings

Given array vals[left,right] of strings, select random index within this range to use for partition.

Author:
George Heineman
Date:
6/15/08

Function Documentation

int selectPivotIndex ( void **  vals,
int  left,
int  right 
)

Code to select a pivot index around which to partition ar[left, right].

Select median element of vals[left], vals[mid], and vals[right] to use.

Parameters:
vals the array of elements.
left the left end of the subarray range
right the right end of the subarray range
Returns:
int in the range [left, right] to use in partition.

This really needs to have the comparison method passed in! But I don't want to change the interface, so this will suffice in the short term since all we have are strings in the example.

Algorithm Development Kit 1.0