-
Notifications
You must be signed in to change notification settings - Fork 0
/
gcode.html
57 lines (47 loc) · 2.02 KB
/
gcode.html
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
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title></title>
<style>
body {padding-top:50px ; margin-top: auto; margin-left: 30px;background-color:#0c7b93;color: white;}
h1 { color: black;text-align: center;}
h3 { color: black;}
p {text-align: center;}
b {color: black;}
</style>
</head>
<body>
<h1>PYTHON CODE</h1>
<br>
<p>
<button onclick="location.href='index.html'">Go to Home Page</button> <br /><br />
</p>
<h3> CODE FOR PRINTING GRAPH</h3>
<div class="">
import matplotlib.pyplot as plt <br>
from random import sample <br>
%matplotlib inline <br>
ns = range(10, 1000, 10000) <br>
ops = []<br>
for n in ns: <br>
my_list = sample(range(n), n) <br>
ops.append(<b>sorting_method</b>(my_list))<br>
plt.plot(ns, ops);<br>
</div>
<h3>sorting_method USING EXAMPLE BUBBLE SORT</h3>
<div class="">
def bubble_sort(a):<br>
not_sorted = True<br>
operations = 0<br>
while not_sorted:<br>
not_sorted = False<br>
for i in range(len(a)-1):<br>
operations += 1<br>
if a[i] > a[i+1]:<br>
a[i], a[i+1] = a[i+1], a[i]<br>
not_sorted = True<br>
return operations<br>
</div>
</body>
</html>