forked from gcallah/algorithms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGettingStarted.html
More file actions
136 lines (117 loc) · 4.27 KB
/
GettingStarted.html
File metadata and controls
136 lines (117 loc) · 4.27 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<html>
<head>
<link href="style.css" rel="stylesheet" type="text/css"/>
<title>
Design and Analyis of Algorithms: Getting Started
</title>
</head>
<body>
<div id="header">
<div id="logo">
<img src="graphics/Julia.png">
</div>
<div id="user-tools">
<a href="index.html">Home</a>
<a href="about.html">About</a>
<a href="feedback.html">Feedback</a>
</div>
</div>
<h1>
Design and Analyis of Algorithms: Getting Started
</h1>
<div style="text-align:center">
<p>
<img src="">
</p>
</div>
<details>
<summary class="sum1">
Overview
</summary>
<details>
<summary class="sum2">
Running code in your browser
</summary>
<p>
Here is Python code for a swap routine, which our textbook
uses periodically:
</p>
<pre>
l = [1, 2, 3]
def swap(l, i, j):
temp = l[i]
l[i] = l[j]
l[j] = temp
</pre>
<p>
Paste that code into the Python console below:
</p>
<figure>
<iframe style="width: 640; height: 480; border: none;"
name="embedded_python_anywhere"
src="https://www.pythonanywhere.com/embedded3/" scrolling="yes"></iframe>
<figcaption>
Python console
</figcaption>
</figure>
<p>
Hit return. Then type 'swap(l, 0, 2)' and hit return.
<br />
Then type 'l'.
<br />
<br />
You should see '[3, 2, 1]': you swapped element 0 and
2!
</p>
<p>
Now type in the following:
</p>
<pre>
def bubble_sort(l):
for i in range(0, len(l) - 1):
for j in range(len(l) - 1, i, -1):
if l[j] < l[j - 1]:
print("Swapping " + str(l[j]) + " and "
+ str(l[j - 1]))
swap(l, j, j - 1)
return l
</pre>
</details>
</details>
<details>
<summary class="sum1">
Source Code
</summary>
<p>
<a href="https://github.com/gcallah/algorithms/tree/master/Java/GettingStarted">Java</a><br>
<a href="https://github.com/gcallah/algorithms/tree/master/Ruby/GettingStarted">Ruby</a><br>
<a href="https://github.com/gcallah/algorithms/tree/master/Go/GettingStarted">Go</a><br>
<a href="https://github.com/gcallah/algorithms/tree/master/C++/GettingStarted">C++</a><br>
<a href="https://github.com/gcallah/algorithms/tree/master/Python/GettingStarted">Python</a><br>
<a href="https://github.com/gcallah/algorithms/tree/master/Clojure/GettingStarted">Clojure</a><br>
</p>
</details>
<details>
<summary class="sum1">
For Further Study
</summary>
<ul>
</ul>
</details>
<details>
<summary class="sum1">
Homework
</summary>
</details>
</body>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-97026578-2', 'auto');
ga('send', 'pageview');
</script>
</html>