Department of Computer Science | Institute of Theoretical Computer Science | CADMO

Theory of Combinatorial Algorithms

Prof. Emo Welzl and Prof. Bernd Gärtner

// Program: sort_array_template.C // read a sequence of n numbers into an array, // sort them using a function, check whether the // sorting is correct, and output the // sorted sequence. // The input to the sorting code can be provided // in a text file. The first entry should indicate // the number of integers to sort, the subsequent // entries are the sequence to sort. Numbers // are separated by whitespaces. #include #include // PRE: [first, last) is a valid range // POST: the elements *p, p in [first, last) are // in ascending order void sort (int* first, int* last) { // insert your sorting code here } int main() { // input of n unsigned int n; std::cin >> n; // dynamically allocate array int* a = new int[n]; // read into the array for (int i=0; i> a[i]; // sort sort (a, a+n); // check whether it's really sorted for (int i=0; i