-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathselection-sort.html
More file actions
235 lines (215 loc) · 11.6 KB
/
Copy pathselection-sort.html
File metadata and controls
235 lines (215 loc) · 11.6 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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="author" content="Viktor Högberg, Léo Tuomenoksa Texier">
<meta name="description"
content="Learn how the Insertion Sort algorithm works through interactive visualization 🔄">
<meta name="generator" content="Visual Studio Code">
<meta name="keywords" content="Selection Sort, Sorting algorithm, Learning, Visualization, Computer science">
<title>SortingLab - Selection sort</title>
<!-- Update numbers for caching err -->
<link rel="stylesheet" href="styles/base.css?rnd=12355">
<link rel="stylesheet" href="styles/game.css?rnd=12355">
<link rel="stylesheet" href="styles/selection-sort.css?rnd=12355">
<!-- Favicon -->
<link rel="icon" type="image/png" href="assets/icons/favicon/favicon-96x96.png" sizes="96x96">
<link rel="icon" type="image/svg+xml" href="assets/icons/favicon/favicon.svg">
<link rel="shortcut icon" href="assets/icons/favicon/favicon.ico">
<link rel="apple-touch-icon" sizes="180x180" href="assets/icons/favicon/apple-touch-icon.png">
<meta name="apple-mobile-web-app-title" content="SortingLab">
<link rel="manifest" href="assets/icons/favicon/site.webmanifest">
</head>
<body>
<header>
<div id="header-container">
<div id="logo-container">
<h1>Sorting<span id="logo-span">Lab</span></h1>
<img src="assets/icons/neural.png" alt="" id="logo">
</div>
<div id="header-button-container">
<button id="theme-toggle-button" title="Toggle Theme"></button>
<div class="audio-toggle">
<input type="checkbox" id="sound-checkbox" name="sound-preference">
<label for="sound-checkbox" id="sound-label"></label>
</div>
<a href="about.html" id="about-button" title="About">About ℹ️</a>
</div>
</div>
</header>
<main>
<h2 id="algorithm-title">Selection sort</h2>
<div id="about-algorithm-container">
<section id="theory-view">
<div class="algorithm-description">
<h3>How it works</h3>
<p>Selection Sort finds the <b>smallest element</b> in the list and moves it to the correct
position,
one step at a time, like selecting the best items from a messy shelf.</p>
<ul>
<li>
<p>🔹 Search through the list to find the smallest item → Swap it with the first unsorted
position → Repeat until sorted.</p>
</li>
<li>
<p>🔹 Best & worst case: Always <b>O(n²)</b> since it searches the entire list every time.
</p>
</li>
<li>
<p>🔹 Why learn it? It's easy to understand and doesn't need extra memory.</p>
</li>
</ul>
<p>👀 Think of it as: Picking the shortest friend in a line and moving them to the front.</p>
</div>
<div class="algorithm-description-code">
<h3>How it works in code</h3>
<div id="code-snippet-container">
<div id="code-snippet-buttons">
<input type="radio" name="code-snippet-button" id="code-snippet-button-javascript" checked>
<label for="code-snippet-button-javascript">JavaScript</label>
<input type="radio" name="code-snippet-button" id="code-snippet-button-python">
<label for="code-snippet-button-python">Python</label>
<input type="radio" name="code-snippet-button" id="code-snippet-button-java">
<label for="code-snippet-button-java">Java</label>
<input type="radio" name="code-snippet-button" id="code-snippet-button-cpp">
<label for="code-snippet-button-cpp">C++</label>
</div>
<div id="code-snippet">
<pre id="code-snippet-display"></pre>
</div>
</div>
</div>
</section>
<section id="game-options-and-instructions-container">
<div class="game-instruction">
<h3>How to play</h3>
<p><b>Goal: </b>Find and move the smallest element into the correct position.</p>
<p><b>Buttons: </b></p>
<ul>
<li>
<p>Next ⏭️ → Move through the list to find the smallest element.</p>
</li>
<li>
<p>Select 🎯 → Marks the smallest element found.</p>
</li>
<li>
<p>Move 🔄 → Moves the selected element to the correct position on the left.</p>
</li>
<li>
<p>Submit ✅ → Checks if the list is fully sorted.</p>
</li>
</ul>
<p>👀 Tip: Once an element is sorted, it turns <b>green</b> and becomes part of the final list!</p>
</div>
<div class="game-options-container">
<h3>Game options</h3>
<p>Choose game preferences: </p>
<div id="game-preference-container" class="option-group">
<label class="custom-checkbox">
<input type="checkbox" id="lives-checkbox">
<span class="checkmark"></span>
Lives
</label>
<label class="custom-checkbox">
<input type="checkbox" id="time-checkbox">
<span class="checkmark"></span>
Time limit
</label>
<label class="custom-checkbox">
<input type="checkbox" id="points-checkbox">
<span class="checkmark"></span>
Disable points
</label>
</div>
<p>Choose game mode: </p>
<div id="game-mode-container" class="option-group">
<label class="custom-radio">
<input type="radio" name="game-mode" id="number-mode" checked>
<span class="radiomark"></span>
Number-mode (123...)
</label>
<label class="custom-radio">
<input type="radio" name="game-mode" id="letter-mode">
<span class="radiomark"></span>
Letter-mode (ABC...)
</label>
</div>
<p>Choose game difficulty (amount of elements): </p>
<div id="game-difficulty-container" class="option-group">
<label class="custom-radio">
<input type="radio" name="game-difficulty" id="easy-difficulty">
<span class="radiomark"></span>
Easy
</label>
<label class="custom-radio">
<input type="radio" name="game-difficulty" id="normal-difficulty" checked>
<span class="radiomark"></span>
Normal
</label>
<label class="custom-radio">
<input type="radio" name="game-difficulty" id="hard-difficulty">
<span class="radiomark"></span>
Hard
</label>
</div>
</div>
</section>
</div>
<button id="start-button"><span>Start</span></button>
<div id="game-view">
<div id="time-and-lives-container">
<div id="time-container">
<p>Time:</p>
<p id="countdown">0:60</p>
</div>
<div id="lives-container">
<p>Lives:</p>
<p id="number-of-lives">❤️❤️❤️</p>
</div>
</div>
<div id="game-element-container">
<div class="game-element game-element-easy"><span class="game-element-text">1</span></div>
<div class="game-element game-element-easy"><span class="game-element-text">2</span></div>
<div class="game-element game-element-easy"><span class="game-element-text">3</span></div>
<div class="game-element game-element-easy"><span class="game-element-text">4</span></div>
<div class="game-element game-element-easy"><span class="game-element-text">5</span></div>
<div class="game-element game-element-normal"><span class="game-element-text">6</span></div>
<div class="game-element game-element-normal"><span class="game-element-text">7</span></div>
<div class="game-element game-element-normal"><span class="game-element-text">8</span></div>
<div class="game-element game-element-normal"><span class="game-element-text">9</span></div>
<div class="game-element game-element-normal"><span class="game-element-text">10</span></div>
<div class="game-element game-element-hard"><span class="game-element-text">11</span></div>
<div class="game-element game-element-hard"><span class="game-element-text">12</span></div>
<div class="game-element game-element-hard"><span class="game-element-text">13</span></div>
<div class="game-element game-element-hard"><span class="game-element-text">14</span></div>
<div class="game-element game-element-hard"><span class="game-element-text">15</span></div>
</div>
<div id="game-control-buttons-container">
<div id="move-buttons-container">
<button id="next-button"><span>Next ⏭️</span></button>
<button id="move-button"><span>Move 🔄</span></button>
<button id="select-button"><span>Select ✅</span></button>
</div>
<button id="submit-button"><span>Submit ✅</span></button>
</div>
</div>
<p id="move-explanation"></p>
<dialog id="game-over-dialog">
<p id="game-over-title">Game over!</p>
<p id="game-over-lives-lost"></p>
<p id="game-over-points"></p>
<p id="game-over-text"></p>
<div id="game-over-buttons">
<button id="try-again-button">Try again 🔁</button>
<button id="return-home-button">Return home 🏠</button>
</div>
</dialog>
</main>
<footer>
</footer>
<script src="scripts/base.js" type="module"></script>
<script src="scripts/algorithms/selection-sort.js" type="module"></script>
<script src="scripts/code-snippets.js"></script>
</body>
</html>