Jump to content

Compare sorting algorithms' performance: Difference between revisions

m
→‎Plot timings: import numpy
m (→‎Plot timings: import numpy)
Line 81:
<code>
import operator
import numpy, pylab
def plotdd(dictplotdict):
"""See ``plot_timings()`` below."""
symbols = ('o', '^', 'v', '<', '>', 's', '+', 'x', 'D', 'd',
'1', '2', '3', '4', 'h', 'H', 'p', '|', '_')
colors = map(None, 'bgrcmyk') # split string on distinct characters
for npoints, plotdict in dictplotdict.iteritems():
for ttle, lst in plotdict.iteritems():
pylab.hold(False)
for i, (label, polynom, x, y) in enumerate(sorted(lst,key=operator.itemgetter(0))):
pylab.plot(x, y, colors[i % len(colors)] + symbols[i % len(symbols)], label='%s %s' % (polynom, label))
label='%s %s' % (polynom, label))
pylab.hold(True)
y = numpy.polyval(polynom, x)
Line 139 ⟶ 138:
plotdd(ds) # see ``plotdd()`` above
</code>
 
===Figures: log2( time in microseconds ) vs. log2( sequence length )===
1 <= N <= 2**10 # an input sequence length
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.