Design patterns for sorting

  • Authors:
  • Dung “Zung” Nguyen;Stephen B. Wong

  • Affiliations:
  • Dept. of Computer Science, Rice University, Houston, TX;Computer Science Program, Oberlin College, Oberlin, OH

  • Venue:
  • Proceedings of the thirty-second SIGCSE technical symposium on Computer Science Education
  • Year:
  • 2001

Quantified Score

Hi-index 0.01

Visualization

Abstract

Drawing on Merritt's divide-and-conquer sorting taxonomy [1], we model comparison-based sorting as an abstract class with a template method to perform the sort by relegating the splitting and joining of arrays to its concrete subclasses. Comparison on objects is carried out via an abstract ordering strategy. This reduces code complexity and simplifies the analyses of the various concrete sorting algorithms. Performance measurements and visualizations can be added without modifying any code by utilizing the decorator design pattern. This object-oriented design not only provides the student a concrete way of unifying seemingly disparate sorting algorithms but also help him/her differentiate them at the proper level of abstraction.