Compare sorting algorithms' performance: Difference between revisions
Content added Content deleted
mNo edit summary |
(added couple of figures with results (links to images)) |
||
Line 28: | Line 28: | ||
'''Interpreter:''' [[Python]] 2.5 |
'''Interpreter:''' [[Python]] 2.5 |
||
[[Category:Python]] |
[[Category:Python]] |
||
=== |
===Examples of sorting routines=== |
||
def builtinsort(x): |
def builtinsort(x): |
||
x.sort() |
x.sort() |
||
Line 76: | Line 76: | ||
===Plot timings=== |
===Plot timings=== |
||
{{library|matplotlib}} |
{{library|matplotlib}} |
||
⚫ | |||
<code> |
<code> |
||
import operator |
import operator |
||
Line 104: | Line 106: | ||
See [[Plot x, y arrays]] and [[Polynomial Fitting]] subtask for basic usage of ''pylab.plot()'' and ''numpy.polyfit()''. |
See [[Plot x, y arrays]] and [[Polynomial Fitting]] subtask for basic usage of ''pylab.plot()'' and ''numpy.polyfit()''. |
||
⚫ | |||
<code> |
<code> |
||
import collections |
import collections |
||
Line 137: | Line 138: | ||
plotdd(ds) # see ``plotdd()`` above |
plotdd(ds) # see ``plotdd()`` above |
||
</code> |
</code> |
||
===Figures: log2( time in microseconds ) vs. log2( sequence length )=== |
|||
sort_functions=[builtinsort, insertion_sort, insertion_sort_lowb, qsort, qsortranlc, qsortranpart, qsortranpartis] |
|||
====ones==== |
|||
[http://bahus.3ka.mipt.ru/gallery/data/public/24.12.07/energy_104231.png ones.png] (143KiB) |
|||
====range==== |
|||
[http://bahus.3ka.mipt.ru/gallery/data/public/24.12.07/energy_105040.png range.png] (145KiB) |