-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSelection_sort.html
190 lines (163 loc) · 6.46 KB
/
Selection_sort.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
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
<!DOCTYPE html>
<html lang="ro">
<head>
<meta charset="utf-8"/>
<title>Selection sort</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="styles/general_style.css">
<link rel="stylesheet" type="text/css" href="styles/selection_style.css">
<link rel="stylesheet" type="text/css" href="styles/theprague/stylesheet.css">
<link rel="icon" href="imagini/sort-by-numeric-order.png" type="image/gif" sizes="16x16">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</head>
<body>
<div id="container">
<div class="item-a">
<nav class="navbar navbar-expand-md navbar-toggleable-sm justify-content-center">
<ul class="navbar-nav">
<li class="nav-item"><a class="nav-link" href="index.html">Home</a></li>
<li class="nav-item"><a class="nav-link" href="Help.html">Help</a></li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbardrop" data-toggle="dropdown">
Sorting Algorithms
</a>
<div class="dropdown-menu">
<a class="dropdown-item" href="Bubble_sort.html">Bubble Sort</a>
<a class="active" href="Selection_sort.html">Selection Sort</a>
<a class="dropdown-item" href="Insertion_sort.html">Insertion Sort</a>
<a class="dropdown-item" href="Shell_sort.html">Shell Sort</a>
<a class="dropdown-item" href="Merge_sort.html">Merge Sort</a>
<a class="dropdown-item" href="Quick_sort.html">Quick Sort</a>
<a class="dropdown-item" href="Heap_sort.html">Heap Sort</a>
</div>
</li>
</ul>
</nav>
<h1 id="title">Selection Sort</h1>
</div>
<div class="item-b">
<div id="algoritm">
<p id="0">for(i=0; i<n-1; i++)</p>
<p>{</p>
<p id="1" class= "p12789">minPoz=i;</p>
<p id="2" class= "p12789">min=x[i];</p>
<p id="3" class= "p3"> for(j=i+1; j < n;j++)</p>
<p class= "pp"> {</p>
<p id="4" class= "p7"> if(min > x[j])</p>
<p class= "pp1"> {</p>
<p id="5" class= "p56"> minPoz=j;</p>
<p id="6" class= "p56"> min=x[j];</p>
<p class= "pp1"> }</p>
<p class= "pp"> }</p>
<p id="7" class= "p12789"> aux=x[i];</p>
<p id="8" class= "p12789"> x[i]=x[minPoz];</p>
<p id="9" class= "p12789"> x[minPoz]=aux;</p>
<p> }</p>
</div>
<script src="script/selection.js">
</script>
<audio id="audio" src="audio/button_push.wav" ></audio>
<div id="buttons">
<button class = "positioning_button" id="quickSort" onclick="QuickSorting()">Sortare Rapida</button>
<button class = "positioning_button" id="slowSort" onclick="Sorting()">Sort</button>
<button class = "positioning_button" onclick="Stop()">Stop</button>
<button class = "positioning_button" id="nextBtn" onclick="Next()">Next</button>
<button class = "positioning_button" id="Set_val" onclick="read_table()">Set values</button>
<h2 id="sort">Incearca algoritmul!</h2>
</div>
</div>
<div class="item-c">
<div id="positioning_text">
<h2>PREZENTAREA METODEI</h2>
<h4> Acest algoritm selecteaza la fiecare pas
cel mai mic element din vectorul de la pasul
i+1 pana la n.Valoarea minima este pozitionata in vector la pozitia i, facandu-se
intereschimbarea cu pozitia actuala a minimului.Nu
este un algoritm indicat pentru vectorii
mari, in majoritatea cazurilor oferind rezultate ma
i slabe decat
insertion sort si bubble sort
. </h4>
<h2>PREZENTAREA ALGORITMULUI</h2>
<h4>Algoritmul de sortarea prin metoda selection va sorta elementele din vectorul v1, v2 ,...,vn astfel
incat dupa sortare, acestea vor fi in ordinea v1 < v2 <... < vn.
Ne propunem sa facem o ordonare crescatoare a vectorului v1, v2 ,...,vn. Algoritmul consta in:</h4>
<h4>Pentru fiecare pozitie i, incepand cu prima, se selecteaza din subtabloul
ce iıncepe cu acea pozitie cel mai mic element , si se amplaseaza
pe locul respectiv (prin interschimbare cu elementul curent
de pe pozitia i).
Ciclul for continua pana la n − 1 deoarece subtabloul v[n,,n] contine un
singur element care este plasat chiar pe pozitia potrivita, ca urmare a interschimbarilor
efectuate anterior.
</h4>
</div>
</div>
<div class="item-d">
<table>
<tr>
<th colspan="20">Tabel de sortare</th>
</tr>
<tr>
<td>X0</td>
<td>X1</td>
<td>X2</td>
<td>X3</td>
<td>X4</td>
<td>X5</td>
<td>X6</td>
<td>X7</td>
<td>X8</td>
<td>X9</td>
<td>X10</td>
<td>X11</td>
<td>X12</td>
<td >X13</td>
<td >X14</td>
<td>X15</td>
<td >X16</td>
<td >X17</td>
<td >X18</td>
<td >X19</td>
</tr>
<tr>
<th id="a"><input type="number" id="a1" /></th>
<th id="b"><input type="number" id="b1" /></th>
<th id="c"><input type="number" id="c1" /></th>
<th id="d"><input type="number" id="d1" /></th>
<th id="e"><input type="number" id="e1" /></th>
<th id="f"><input type="number" id="f1" /></th>
<th id="g"><input type="number" id="g1" /></th>
<th id="h"><input type="number" id="h1" /></th>
<th id="j"><input type="number" id="j1" /></th>
<th id="k"><input type="number" id="k1" /></th>
<th id="l"><input type="number" id="l1" /></th>
<th id="m"><input type="number" id="m1" /></th>
<th id="n"><input type="number" id="n1" /></th>
<th id="o"><input type="number" id="o1" /></th>
<th id="p"><input type="number" id="p1" /></th>
<th id="q"><input type="number" id="q1" /></th>
<th id="r"><input type="number" id="r1" /></th>
<th id="s"><input type="number" id="s1" /></th>
<th id="t"><input type="number" id="t1" /></th>
<th id="u"><input type="number" id="u1" /></th>
</tr>
</table>
<div id="sortInfo">
<h2 id="sorth2"> Timpuri de executare:</h2>
<ol>
<li>Cazul mediu : O(N^2)</li>
<li>Cazul defavorabil : O(N^2)</li>
<li>Cazul cel mai bun: O(N^2)</li>
<li>Memorie folosita : O(1)</li>
<li>Stabil : DA</li>
<li>Sortare descrescatoare : min < a[i+1]</li>
<li>Sortare crescatoare : min > a[i+1]</li>
</ol>
</div>
</div>
</div>
</body>
</html>