Order graph using python for comparing time complexity


import math
import numpy as np
import matplotlib.pyplot as plt 

n = np.arange(5, 10, 0.1)
y = [nn*np.log(nn) for nn in n]
plt.plot(n,y,label="n*log(n)")
y = n 
plt.plot(n,y,label="n")
y = [np.log(nn)**2 for nn in n]
plt.plot(n,y,label="log(n)**2")
y = n**(1/2)
plt.plot(n,y,label="n**(1/2)")
y = [np.log(nn) for nn in n]
plt.plot(n,y,label="log(n)")
plt.legend()
plt.show()

n = np.arange(1,6,1)
y = [math.factorial(nn) for nn in n]
plt.plot(n,y,label="n!")
y = 2**n
plt.plot(n,y,label="2**n")
y = n**2
plt.plot(n,y,label="n**2")
y = n*(n**(1/2))
plt.plot(n,y,label="n*(n**(1/2)")
y = [np.log(nn) for nn in n]
plt.plot(n,y,label="log(n)")
plt.legend()
plt.show()



log(n) < n^(1/2) < log(n)^2 < n < n*log(n) < n*(n^(1/2)) < n^2 < 2^n < n!

Refs.