--- title: Plots layout: plots groups: - navbar navbar_link:  Plots custom_css: plots.css input_order: - ascending - random - descending plots: - codename: bubble_sort brief_name: Bubble sort display_name: Bubble sort min_length: 0 max_length: 200 iterations: 100 complexity: ascending: O(n) random: O(n2) descending: O(n2) - codename: bubble_sort_optimized brief_name: "… \"optimized\"" display_name: "\"Optimized\" bubble sort" min_length: 0 max_length: 200 iterations: 100 complexity: ascending: O(n) random: O(n2) descending: O(n2) - codename: heapsort brief_name: Heapsort display_name: Heapsort min_length: 0 max_length: 200 iterations: 100 complexity: O(n log n) - codename: insertion_sort brief_name: Insertion sort display_name: Insertion sort min_length: 0 max_length: 200 iterations: ascending: 1000 random: 100 descending: 100 complexity: ascending: O(n) random: O(n2) descending: O(n2) - codename: merge_sort brief_name: Merge sort display_name: Merge sort min_length: 0 max_length: 200 iterations: 1000 complexity: O(n log n) - codename: quicksort_first brief_name: Quicksort (first element as pivot) display_name: Quicksort (first element as pivot) min_length: 0 max_length: 200 iterations: 100 complexity: ascending: O(n2) random: O(n log n) descending: O(n2) - codename: quicksort_second brief_name: "… second element…" display_name: Quicksort (second element as pivot) min_length: 0 max_length: 200 iterations: 100 complexity: ascending: O(n2) random: O(n log n) descending: O(n2) - codename: quicksort_middle brief_name: "… middle element…" display_name: Quicksort (middle element as pivot) min_length: 0 max_length: 200 iterations: 100 complexity: O(n log n) - codename: quicksort_last brief_name: "… last element…" display_name: Quicksort (last element as pivot) min_length: 0 max_length: 200 iterations: 100 complexity: ascending: O(n2) random: O(n log n) descending: O(n2) - codename: quicksort_random brief_name: "… random element…" display_name: Quicksort (random element as pivot) min_length: 0 max_length: 200 iterations: 100 complexity: O(n log n) - codename: selection_sort brief_name: Selection sort display_name: Selection sort min_length: 0 max_length: 200 iterations: 100 complexity: O(n2) ---

Plots

The goals of this "project" include a) familiarizing myself with a few sorting algorithms by examining their (possibly, simplified) implementations and b) studying the way algorithm's running time changes in relation to the length of its input (a.k.a. identifying its time complexity).

A simple way to visualize the way algorithm's running time changes would be to make appropriate measurements and plot them on a nice graph. The results of course are highly dependent on the hardware used, while the graph's look depends on the software used for rendering.

Both the hardware & the software that were used to produce the plots are listed below.

CPU Intel Core i3-5005U
OS Windows 8.1
Python 3.5.1
matplotlib 1.5.1
{% if page.plots and page.plots != empty %}

The table & plots below are just an attempt to nicely lay out the data generated using the code from the project repository's master branch. Visit https://github.com/egor-tensin/sorting_algorithms/ for more details.

In short, each of the implemented algorithms was provided with three input sequences:

Use the table below to quickly navigate to the plots for the corresponding algorithm.

{% for order in page.input_order %} {% endfor %} {% for algorithm in page.plots %} {% for order in page.input_order %} {% endfor %} {% endfor %}
Algorithm Complexity
{{ order }}
{{ algorithm.brief_name }}{% if algorithm.complexity[order] %}{{ algorithm.complexity[order] }}{% else %}{{ algorithm.complexity }}{% endif %}
{% for algorithm in page.plots %}

{{ algorithm.display_name }}

{% for order in page.input_order %} {% if algorithm.iterations[order] %} {% assign iterations = algorithm.iterations[order] %} {% else %} {% assign iterations = algorithm.iterations %} {% endif %} {% capture stem %}{{ algorithm.codename }}_{{ iterations }}_{{ order }}_{{ algorithm.min_length }}_{{ algorithm.max_length }}{% endcapture %}
{{ algorithm.display_name | escape }}, {{ iterations }} iterations, {{ order }} input
{{ algorithm.display_name }}
Input: {{ order }}
Complexity: {% if algorithm.complexity[order] %}{{ algorithm.complexity[order] }}{% else %}{{ algorithm.complexity }}{% endif %}
{% endfor %}
{% endfor %} {% else %}

Sorry, not plots have been added yet.


{% endif %}