-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
57 lines (44 loc) · 863 Bytes
/
main.py
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
import time
import matplotlib.pyplot as plt
#?? O(n)?
def complexidade(n):
inicio = time.time()
while n > 0:
n -= 1
fim = time.time()
return fim-inicio
#?? O(log*n)?
def complexidade2(n):
inicio = time.time()
while n > 0:
n = n/2
fim = time.time()
return fim-inicio
#?? O(1)?
def complexidade3(n):
inicio = time.time()
n = n**2
n = n**2
fim = time.time()
return fim-inicio
temp_comp = []
temp_comp2 = []
temp_comp3 = []
for i in range(1, 100000, 1000):
temp_comp.append(complexidade(i))
for i in range(1, 100000, 1000):
temp_comp2.append(complexidade2(i))
for i in range(1, 100000, 1000):
temp_comp3.append(complexidade3(i))
'''
print(temp_comp)
print()
print(temp_comp2)
print()
print(temp_comp3)
'''
x = range(1, 100000, 1000)
plt.plot(x, temp_comp)
plt.plot(x, temp_comp2)
plt.plot(x, temp_comp3)
plt.show()