Skip to content

feliciahsieh/SortingAlgorithms

Repository files navigation

Sorting Algorithms

Welcome

Here are my implementations of popular sorting algorithms in python. The benefits of Python made it easier, more compact, and faster to code than C. As each round of sorting happens, the current state is printed to the screen.

My C sorting algorithms are in a separate GitHub repo.

Table of Contents

About

This repository contains 7 sorting algorithms with an extra Quicksort variant. The Big Oh Notations are added as a general reference, but this is not the definitive table. Big Oh Notations vary depending on the implementation and in some cases can be subjective. YMMV.

Algorithm Best Average Worst
Bubble sort n n^2 n^2
Heap sort nlog(n) nlog(n) nlog(n)
Insertion sort n n^2 n^2
Merge sort n n^2 n^2
Quicksort1 (the traditional way) nlog(n) nlog(n) n^2
Quicksort2 (using python lists) nlog(n) nlog(n) n^2
Selection sort n^2 n^2 n^2
Shellsort nlog(n) Depends n^2

Requirements

  • Ubuntu (v14.04 LTS)
  • Python (v3.4.3)
  • Pycodestyle (v2.4.0) (linter)

All programs were run on a Vagrant(ubuntu/trusty64) (Virtualbox) environment

Installation

In your terminal, git clone the directory with the following command:

git clone https://github.com/feliciahsieh/SortingAlgorithms.git

Usage

Type the sorting algorithm you want to run in python. All of the programs measure the time it takes for processing the program using the SAME list of integers. Currently, each sorting algorithm uses the following.

[23, 6, 1, 90, 30, 39, 99, 15, 88, 0]

The output will look similar to the following:

EVERY sorting algorithm can be run once with:

./runsort.py

or EACH sorting algorithm can be run as needed:

./bubblesort.py
./heapsort.py
./insertionsort.py
./mergesort.py
./quicksort1.py
./quickSort2.py
./selectionsort.py
./shellsort.py

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages