// From the software distribution accompanying the textbook // "A Practical Introduction to Data Structures and Algorithm Analysis, // Third Edition" by Clifford A. Shaffer, Prentice Hall, 2007. // Source code Copyright (C) 2006 by Clifford A. Shaffer. // A program to compare the time required to do a simple binsort // using two arrays versus a binsort that swaps "in place". Thus, // the first version uses twice the space (since it requires an // auxilliary array), while the second version does extra copying // (because a swap is more expensive than a direct copy). #include using namespace std; #include "book.h" #include "permute.h" #define COUNT 100 typedef int Elem; #include "list.h" int MaxKeyValue = 100; // dummy declaration for binsort.x syntax check // Check syntax for binsort code template void binsort(Elem A[], int n) { List B[MaxKeyValue]; Elem item; for (int i=0; i"); n = atoi(argv[1]); A = new Elem[n]; B = new Elem[n]; Randomize(); for (i=0; i