[prev] 12 [next]

Exercise 3: SortLab

Implement a "sorting laboratory", a program that allows us to
  • testbed for sorting algorithms
  • users choose algorithm, initial order, size
  • runs algorithm and counts compares + swaps
  • doesn't have a fancy GUI ...

$ ./sorter
Usage: ./sorter Algo Size Dist [Seed]
Algo = b|i|m|q|s, Dist = A|D|R
$ ./sorter b 10 R
Before:  79 70 69 17 89 07 02 56 30 86
After:   02 07 17 30 56 69 70 79 86 89
#compares: 44, #swaps: 27, #moves: 0
OK