Skip to content

mx-psi/sorting

Repository files navigation

Sorting

Sorting is a plotter of sorting algorithms. It creates a video representing the changes an algorithm makes to a set of data. It uses python2, matplotlib and avconv or ffmpeg. The original concept was taken from The Glowing Python.

Usage

Algorithm

The sorting algorithm should be provided as a function inside a Python module, adding the functions provided in sorting.py.

The functions that should be included in the algorithm for its plotting are:

  • sorting.start(): Returns a list with a random permutation.
  • sorting.swap(i,j): Swaps the contents of data[i] and data[j].
  • sorting.iteration(): Plots current iteration.
  • sorting.end(): Finishes plotting and starts doing the video.

Calling the program

Sorting uses Python's optparser module for parsing options. It includes various options such as plotting swaps, two different ways of plotting the algorithm and adjustment of data size and frame rate. You may call plot.py -h for usage and information about options.

About

A programming exercise on sorting algorithms.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages