generated from kolliden/sorting-javascript-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCocktail-Sort.htm
55 lines (55 loc) · 3.98 KB
/
Cocktail-Sort.htm
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
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Bubble Sort</title>
</head>
<body onresize="initCanvas()">
<canvas id="cv" style=' left:0px; top:0px;'></canvas>
<div>
<p>"Cocktail sort has a worst-case and average complexity of
<svg xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" width="6.032ex" height="3.176ex" style="vertical-align: -0.838ex;" viewBox="0 -1006.6 2596.9 1367.4" role="img" focusable="false" aria-labelledby="MathJax-SVG-1-Title">
<title id="MathJax-SVG-1-Title">{\displaystyle O(n^{2})}</title>
<defs aria-hidden="true">
<path stroke-width="1" id="E1-MJMATHI-4F" d="M740 435Q740 320 676 213T511 42T304 -22Q207 -22 138 35T51 201Q50 209 50 244Q50 346 98 438T227 601Q351 704 476 704Q514 704 524 703Q621 689 680 617T740 435ZM637 476Q637 565 591 615T476 665Q396 665 322 605Q242 542 200 428T157 216Q157 126 200 73T314 19Q404 19 485 98T608 313Q637 408 637 476Z"/>
<path stroke-width="1" id="E1-MJMAIN-28" d="M94 250Q94 319 104 381T127 488T164 576T202 643T244 695T277 729T302 750H315H319Q333 750 333 741Q333 738 316 720T275 667T226 581T184 443T167 250T184 58T225 -81T274 -167T316 -220T333 -241Q333 -250 318 -250H315H302L274 -226Q180 -141 137 -14T94 250Z"/>
<path stroke-width="1" id="E1-MJMATHI-6E" d="M21 287Q22 293 24 303T36 341T56 388T89 425T135 442Q171 442 195 424T225 390T231 369Q231 367 232 367L243 378Q304 442 382 442Q436 442 469 415T503 336T465 179T427 52Q427 26 444 26Q450 26 453 27Q482 32 505 65T540 145Q542 153 560 153Q580 153 580 145Q580 144 576 130Q568 101 554 73T508 17T439 -10Q392 -10 371 17T350 73Q350 92 386 193T423 345Q423 404 379 404H374Q288 404 229 303L222 291L189 157Q156 26 151 16Q138 -11 108 -11Q95 -11 87 -5T76 7T74 17Q74 30 112 180T152 343Q153 348 153 366Q153 405 129 405Q91 405 66 305Q60 285 60 284Q58 278 41 278H27Q21 284 21 287Z"/>
<path stroke-width="1" id="E1-MJMAIN-32" d="M109 429Q82 429 66 447T50 491Q50 562 103 614T235 666Q326 666 387 610T449 465Q449 422 429 383T381 315T301 241Q265 210 201 149L142 93L218 92Q375 92 385 97Q392 99 409 186V189H449V186Q448 183 436 95T421 3V0H50V19V31Q50 38 56 46T86 81Q115 113 136 137Q145 147 170 174T204 211T233 244T261 278T284 308T305 340T320 369T333 401T340 431T343 464Q343 527 309 573T212 619Q179 619 154 602T119 569T109 550Q109 549 114 549Q132 549 151 535T170 489Q170 464 154 447T109 429Z"/>
<path stroke-width="1" id="E1-MJMAIN-29" d="M60 749L64 750Q69 750 74 750H86L114 726Q208 641 251 514T294 250Q294 182 284 119T261 12T224 -76T186 -143T145 -194T113 -227T90 -246Q87 -249 86 -250H74Q66 -250 63 -250T58 -247T55 -238Q56 -237 66 -225Q221 -64 221 250T66 725Q56 737 55 738Q55 746 60 749Z"/>
</defs>
<g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)" aria-hidden="true">
<use xlink:href="#E1-MJMATHI-4F" x="0" y="0"/>
<use xlink:href="#E1-MJMAIN-28" x="763" y="0"/>
<g transform="translate(1153,0)">
<use xlink:href="#E1-MJMATHI-6E" x="0" y="0"/>
<use transform="scale(0.707)" xlink:href="#E1-MJMAIN-32" x="849" y="583"/>
</g>
<use xlink:href="#E1-MJMAIN-29" x="2207" y="0"/>
</g>
</svg>
,(just like bubble sort) where n is the number of items being sorted. Most practical sorting algorithms have substantially better worst-case or average complexity."</p>
<p>- https://en.wikipedia.org/wiki/Bubble_sort</p>
</div>
<button id="bsstart" onclick="start()"><h1>Start sorting!</h1></button>
<script type="text/javascript" src="main.js" defer></script>
<style>
body {
margin: 0px;
border: 0;
/* overflow: hidden; */
/* Disable scrollbars */
display: block;
/* No floating content on sides */
}
button{
width: 100%;
height: 5vh;
background-color: blueviolet;
justify-content: center;
align-items: center;
border: 0ch;
margin: 0px;
}
</style>
</body>
</html>