aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/plots.html
blob: 2ee6a41d93e3ee1b4574bcd89eb42f939e67fe3e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
---
title: Plots
layout: plots
groups:
  - navbar
navbar_link: <span class="glyphicon glyphicon-th-large"></span>&nbsp;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(<var>n</var>)
      random: O(<var>n</var><sup>2</sup>)
      descending: O(<var>n</var><sup>2</sup>)
  - codename: bubble_sort_optimized
    brief_name: "&hellip; \"optimized\""
    display_name: "\"Optimized\" bubble sort"
    min_length: 0
    max_length: 200
    iterations: 100
    complexity:
      ascending: O(<var>n</var>)
      random: O(<var>n</var><sup>2</sup>)
      descending: O(<var>n</var><sup>2</sup>)
  - codename: heapsort
    brief_name: Heapsort
    display_name: Heapsort
    min_length: 0
    max_length: 200
    iterations: 100
    complexity: O(<var>n</var> log <var>n</var>)
  - 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(<var>n</var>)
      random: O(<var>n</var><sup>2</sup>)
      descending: O(<var>n</var><sup>2</sup>)
  - codename: merge_sort
    brief_name: Merge sort
    display_name: Merge sort
    min_length: 0
    max_length: 200
    iterations: 1000
    complexity: O(<var>n</var> log <var>n</var>)
  - 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(<var>n</var><sup>2</sup>)
      random: O(<var>n</var> log <var>n</var>)
      descending: O(<var>n</var><sup>2</sup>)
  - codename: quicksort_second
    brief_name: "&hellip; second element&hellip;"
    display_name: Quicksort (second element as pivot)
    min_length: 0
    max_length: 200
    iterations: 100
    complexity:
      ascending: O(<var>n</var><sup>2</sup>)
      random: O(<var>n</var> log <var>n</var>)
      descending: O(<var>n</var><sup>2</sup>)
  - codename: quicksort_middle
    brief_name: "&hellip; middle element&hellip;"
    display_name: Quicksort (middle element as pivot)
    min_length: 0
    max_length: 200
    iterations: 100
    complexity: O(<var>n</var> log <var>n</var>)
  - codename: quicksort_last
    brief_name: "&hellip; last element&hellip;"
    display_name: Quicksort (last element as pivot)
    min_length: 0
    max_length: 200
    iterations: 100
    complexity:
      ascending: O(<var>n</var><sup>2</sup>)
      random: O(<var>n</var> log <var>n</var>)
      descending: O(<var>n</var><sup>2</sup>)
  - codename: quicksort_random
    brief_name: "&hellip; random element&hellip;"
    display_name: Quicksort (random element as pivot)
    min_length: 0
    max_length: 200
    iterations: 100
    complexity: O(<var>n</var> log <var>n</var>)
  - codename: selection_sort
    brief_name: Selection sort
    display_name: Selection sort
    min_length: 0
    max_length: 200
    iterations: 100
    complexity: O(<var>n</var><sup>2</sup>)
---
<h1>Plots</h1>

<div class="row">
  <div class="col-xs-12 col-sm-10 col-md-8">
    <p class="text-muted">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).</p>
    <p class="text-muted">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.</p>
    <p class="text-muted">Both the hardware &amp; the software that were used
to produce the plots are listed below.</p>
    <table class="table table-bordered reasonable-width">
      <tr>
        <th>CPU</th>
        <td><a href="http://ark.intel.com/products/84695/Intel-Core-i3-5005U-Processor-3M-Cache-2_00-GHz">Intel Core i3-5005U</a></td>
      </tr>
      <tr>
        <th>OS</th>
        <td>Windows 8.1</td>
      </tr>
      <tr>
        <th>Python</th>
        <td>3.5.1</td>
      </tr>
      <tr>
        <th>matplotlib</th>
        <td>1.5.1</td>
      </tr>
    </table>
  </div>
</div>

{% if page.plots and page.plots != empty %}
<div class="row">
  <div class="col-xs-12 col-sm-10 col-md-8">
    <p>The table &amp; plots below are just an attempt to nicely lay out the
data generated using the code from the project repository's <code>master</code>
branch.
Visit <a href="https://github.com/egor-tensin/sorting-algorithms/">https://github.com/egor-tensin/sorting-algorithms/</a> for more details.</p>

    <p>In short, each of the implemented algorithms was provided with three
input sequences:</p>
    <ul>
      <li>a list of <var>n</var> consecutive numbers sorted in ascending order,</li>
      <li>&hellip; in descending order,</li>
      <li>&hellip; in random order.</li>
    </ul>
    <p>Use the table below to quickly navigate to the plots for the
corresponding algorithm.</p>

    <table class="table table-bordered table-hover">
      <thead>
        <tr>
          <th class="text-center" rowspan="2">Algorithm</th>
          <th class="text-center" colspan="{{ page.input_order.size }}">Complexity</th>
        </tr>
        <tr>
          {% for order in page.input_order %}
            <th class="text-center">{{ order }}</th>
          {% endfor %}
        </tr>
      </thead>
      <tbody>
{% for algorithm in page.plots %}
<tr>
  <td><a href="#plots_{{ algorithm.codename }}">{{ algorithm.brief_name }}</a></td>
  {% for order in page.input_order %}
    <td>{% if algorithm.complexity[order] %}{{ algorithm.complexity[order] }}{% else %}{{ algorithm.complexity }}{% endif %}</td>
  {% endfor %}
</tr>
{% endfor %}
      </tbody>
    </table>
  </div>
</div>

{% for algorithm in page.plots %}
<a id="plots_{{ algorithm.codename }}"></a>
<h3>{{ algorithm.display_name }}</h3>
<div class="row">
  {% 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 %}
    <div class="col-xs-12 col-sm-6 col-md-4">
      <div class="thumbnail">
        <a class="thumbnail" href="{{ site.baseurl }}/img/plots/full_size/{{ stem }}.png">
          <img class="img-responsive" src="{{ site.baseurl }}/img/plots/previews/{{ stem }}.png" alt="{{ algorithm.display_name | escape }}, {{ iterations }} iterations, {{ order }} input"/>
        </a>
        <div class="caption">
          <strong>{{ algorithm.display_name }}</strong><br/>
          <strong>Input:</strong> {{ order }}<br/>
          <strong>Complexity:</strong> {% if algorithm.complexity[order] %}{{ algorithm.complexity[order] }}{% else %}{{ algorithm.complexity }}{% endif %}<br/>
        </div>
      </div>
    </div>
  {% endfor %}
</div>
{% endfor %}

{% else %}
<h3>Sorry, not plots have been added yet.</h3>
<hr/>
{% endif %}