Double sorting: testing their sorting skills

  • Authors:
  • Darrah P. Chavey

  • Affiliations:
  • Beloit College, Beloit, WI, USA

  • Venue:
  • Proceedings of the 41st ACM technical symposium on Computer science education
  • Year:
  • 2010

Quantified Score

Hi-index 0.01

Visualization

Abstract

You're teaching elementary sorting techniques, and you would like your students to do a programming assignment that tests their understanding of the ideas. But all of the code for elementary sorting techniques are in the textbook, easily found on the Web, etc. We suggest the use of two "Double Sorting" techniques whose solution is not standardly available, are fairly straight-forward to code, and offer speed improvements over the "straight" sorts. Double Sorting, the idea of processing two chosen elements simultaneously, applies to both Insertion Sort and Selection Sort, with speedups of 33% and 25%, hence are good enough to justify coding, but not good enough to be in Web collections. Code for this can be written in as little as a dozen lines of C++/Java code, and is easily within the reach of introductory students who understand the basic algorithms. In addition, the ideas used for double sorting are natural first steps in understanding how the N2 sorts can be improved towards the N log N sorts that they will study later. For more advanced students, these double sorts also generate good exercises in the analysis of algorithms.