CO311: Introduction to Modern Programming II

the ShowSort example program

This program has several purposes, but the primary use is to demonstrate the relative efficacy of various sorting algorithms.

The version documented here utilizes a fixed array of 1000 integers, of which any number of elements may be used in the sort routine. Further versions will be implemented that show the distinction between using arrays and linked lists, as well as the implementations provided in the C++ Standard Template Library, which are frequently a hybrid of the two.

The example program is broken into many files, but all of them can be generally grouped into one of three areas:

  1. Control functions
  2. Utility/Support functions
  3. Sorting algorithms

Control Functions

These functions serve to control or “operate” the program. They provide the main interface for user input prior to handing over the data to be sorted to the sorting algorithms. In the current implementation, there are two implementation files and one header:

showsort.cpp
ezwsort.h, ezwsort.cpp

The OS entry point function (ApiMain(), as required by the EasyWin API) is located in the first file, as well as several other functions used to set up the run parameters of the sorting routines. The other files provide an entry point into the graphical sorting routines. As new implementations are added to the example, this pair of files will be updated to provide the additional functionality to calling programs.

Utility/Support functions

These functions provide several functions that are shared by many of the other algorithms in the entire package.

ezwutils.h, ezwutils.cpp
ezwswap.h, ezwswap.cpp
ezwmove.h, ezwmove.cpp

The first pair of files provide definition and implementation of functions used as utilites for manipulating the process/progress of sorting (delays and image highlighting) or to support multiple sorting algorithms (finding the largest and/or the smallest element in a set). The next two files provide an almost universally required set of functions for exchanging the data in a given pair of locations. Because a swap is actually a set of three individual moves, and because some algorithms implement single moves, as opposed to exchanges, the remaining files provide the kernel of an exchange: a set of move functions.

Sorting algorithms

The following files represent each individual sorting algorithm as it relates to visually displaying the process/progress of sorting.

Simple Iterative Sort
ezwworst.h, ezwworst.cpp
“Bubble” Sort
ezwbubbl.h, ezwbubbl.cpp
Bi-directional “Bubble” Sort
ezw2wbub.h, ezw2wbub.cpp
“Shell” Sort
ezwshell.h, ezwshell.cpp
Selection Sort
ezwselec.h, ezwselec.cpp
Insertion Sort
ezwinsrt.h, ezwinsrt.cpp
Recursive “QuickSort”
ezwquick.h, ezwquick.cpp