Created
November 23, 2014 03:35
-
-
Save 0xKD/8e30ceb411b67772af56 to your computer and use it in GitHub Desktop.
Simple Complexity chart (IPython notebook & matplotlib)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
import matplotlib.pyplot as plt | |
%matplotlib inline | |
a = range(1,100) | |
b = map(lambda x:x*math.log(x,2), a) | |
c = map(lambda x:x*x, a) | |
d = map(lambda x:2**x, a) | |
p = plt.figure() | |
sbp = p.add_subplot(1,1,1) | |
sbp.plot(a,b,'r', label=r'$n\log n$') | |
sbp.plot(a,a,'b', label=r'$n$') | |
sbp.plot(a,c,'c', label=r'$n^2$') | |
sbp.plot(a,d,'m', label=r'$2^n$') | |
sbp.set_ylim([0, 1000]) | |
sbp.legend(loc=1) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment