-
Notifications
You must be signed in to change notification settings - Fork 0
/
selectionSort.html
75 lines (74 loc) · 3.32 KB
/
selectionSort.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="default.css" />
<script type="text/javascript" src="array.js"></script>
</head>
<body>
<div id="head">
<h1>Selection Sort</h1>
</div>
<div id="nav">
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="quickSort.html">Quick Sort</a></li>
<li><a href="selectionSort.html">Selection Sort</a></li>
<li>Binary Tree</li>
<li>algorithm</li>
<li>algorithm</li>
<li>algorithm</li>
<li>FAQ</li>
<li>Design</li>
<li>Journal</li>
<li><a href="mailto:[email protected]?Subject=Contact">Contact Us</a></li>
</ul>
</div>
<div id="content">
<div id="display">
<p>
<button type="button" onclick="randomize()">Random</button>
<button type="button" onclick="runSelectionSort()">Start</button>
<button type="button" onclick="pause()">Pause</button>
<span>Speed:</span>
<input id="speed" type="range" min="0" max="100" value="50" step="1" onchange="showValue(this.value, 'speedRange')" />
<span id="speedRange">50</span>
<span>Array Size:</span>
<input id ="arraySize" type ="range" min ="5" max ="30" value="15" step="1" onchange="showValue(this.value,'arraySizeRange')" />
<span id="arraySizeRange">15</span>
(to redraw array, click "randomize")
</p>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="1000" height="200">
<g id="simulationArea">
</g>
</svg>
</div>
<div id = "psuedocode">
<ul type="none">
<li id="l0"><b>function selectionSort(</b><i>array</i><b>)</b></li>
<ul type="none">
<li id="l1"><b>for</b>(<i>outerIndex</i> from 0 to <i>array.length-2</i>)</li>
<ul type="none">
<li id="l2"><i>minIndex</i> = <i>outerIndex</i></li>
<li id="l3"><b>for</b>(<i>innerIndex</i> from <i>outerIndex</i> to <i>array.length-1</i>)</li>
<ul type="none">
<li id="l4"><b>if</b> (<i>array[innerIndex]</i> < <i>array[minIndex]</i>) </li>
<ul type="none">
<li id="l5"><i>minIndex</i> = <i>innerIndex</i></li>
</ul>
</ul>
<li id="l6"><b>swap</b>(<i>array[outerIndex]</i>,<i>array[minIndex]</i>)</li>
</ul>
</ul>
</ul>
</div>
<div id = "summary">
<ol id ="summaryOL">
</ol>
</div>
</div>
</body>
</html>