#include <stdlib.h>
#include <getopt.h>
#include <string.h>
#include <stdio.h>
#include "buildPointerBasedInput.h"
#include "problem.h"
#include "report.h"
Functions | |
int | stringComp (char *a1, char *a2) |
comparator function for comparing two strings. | |
int | ascending (const void *a1, const void *a2) |
default ascending operator provided externally | |
int | descending (const void *a1, const void *a2) |
comparator function for descending order. | |
void | killer (char *combined, int numElements) |
Take sorted/ascending set and permute into killer-of-median-quicksort order. | |
void | prepareInput (int size, int argc, char **argv) |
Construct a random string of size ssize and have 'str1' and 'str2' be allocated strings with the same contents. | |
void | postInputProcessing () |
After sorting, can check whether sort succeeded. | |
void | execute () |
Execute by invoking malloc(numElements) a total of numT times. | |
void | problemUsage () |
No specific problem usage. | |
Variables | |
char ** | strings |
information where input is stored. | |
int | groupingSize = 5 |
The size of the grouping is determined elsewhere. |
Required Input:
Input flags:
For use by other modules:
int groupingSize = 5; default value is 5. Used by worst case select Kth algorithm.
int ascending | ( | const void * | a1, | |
const void * | a2 | |||
) |
default ascending operator provided externally
int descending | ( | const void * | a1, | |
const void * | a2 | |||
) |
comparator function for descending order.
void execute | ( | ) |
Execute by invoking malloc(numElements) a total of numT times.
.numElements
output sum to be sure is correct.
void killer | ( | char * | combined, | |
int | numElements | |||
) |
Take sorted/ascending set and permute into killer-of-median-quicksort order.
implementation derived from: http://ralphunden.net/content/tutorials/a-guide-to-introsort/
Note that the data is contiguous and we must swap as required large sequence of bytes (oh well; it won't count against costs).
void postInputProcessing | ( | ) |
After sorting, can check whether sort succeeded.
void prepareInput | ( | int | size, | |
int | argc, | |||
char ** | argv | |||
) |
Construct a random string of size ssize and have 'str1' and 'str2' be allocated strings with the same contents.
use character-swapping algorithm from strfry.c in glibc
http://www.koders.com/c/fidBD83E492934F9F671DE79B11E6AC0277F9887CF5.aspx
terminate at word boundary, not including spaces.
void problemUsage | ( | ) |
No specific problem usage.
int stringComp | ( | char * | a1, | |
char * | a2 | |||
) |
comparator function for comparing two strings.
int groupingSize = 5 |
The size of the grouping is determined elsewhere.
char** strings |
information where input is stored.
Algorithm Development Kit 1.0