This repository has been archived by the owner on Oct 19, 2022. It is now read-only.
forked from RodrigoDLPontes/visualization-tool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CocktailSort.html
90 lines (66 loc) · 3.44 KB
/
CocktailSort.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
<html>
<head>
<title>
Cocktail Shaker Sort Visualization
</title>
<!-- css sheet for how the page is laid out -->
<link rel="stylesheet" href="visualizationPageStyle.css">
<!-- jqueury stuff. Only used for the animation speed slider. -->
<link rel="stylesheet" href="ThirdParty/jquery-ui-1.8.11.custom.css">
<script src="ThirdParty/jquery-1.5.2.min.js"></script>
<script src="ThirdParty/jquery-ui-1.8.11.custom.min.js"></script>
<!-- Javascript for the actual visualization code -->
<script type="application/javascript" src="AnimationLibrary/CustomEvents.js"> </script>
<script type="application/javascript" src="AnimationLibrary/UndoFunctions.js"> </script>
<script type="application/javascript" src="AnimationLibrary/AnimatedObject.js"> </script>
<script type="application/javascript" src="AnimationLibrary/AnimatedLabel.js"> </script>
<script type="application/javascript" src="AnimationLibrary/AnimatedCircle.js"> </script>
<script type="application/javascript" src="AnimationLibrary/AnimatedRectangle.js"> </script>
<script type="application/javascript" src="AnimationLibrary/AnimatedLinkedList.js"> </script>
<script type="application/javascript" src="AnimationLibrary/HighlightCircle.js"> </script>
<script type="application/javascript" src="AnimationLibrary/Line.js"> </script>
<script type="application/javascript" src="AnimationLibrary/ObjectManager.js"> </script>
<script type="application/javascript" src="AnimationLibrary/AnimationMain.js"> </script>
<script type="application/javascript" src="AlgorithmLibrary/Algorithm.js"> </script>
<script type="application/javascript" src="AlgorithmLibrary/CocktailSort.js"> </script>
<script type="application/javascript" src="OtherLibrary/ExamplesToggle.js"> </script>
</head>
<body onload="init();" class="VisualizationMainPage">
<div id="container">
<div id="header">
<h1>Cocktail Shaker Sort</h1>
</div>
<div id="mainContent">
<div id="algoControlSection">
<!-- Table for buttons to control specific animation (insert/find/etc) -->
<!-- (filled in by javascript code specific to the animtion) -->
<table id="AlgorithmSpecificControls"> </table>
<button id="examplesButton" onclick="toggleExamples()"></button>
</div>
<!-- Drawing canvas where all animation is done. Note: can be resized in code -->
<canvas id="canvas" width="1000" height="503"></canvas>
<div id="generalAnimationControlSection">
<!-- Table for buttons to control general animation (play/pause/undo/etc) ->
<!-- (filled in by javascript code, specifically AnimationMain.js) -->
<table id="GeneralAnimationControls"> </table>
</div>
<div class="modal" id="examplesModal">
<div class="modal-content">
<ul>
<li>The best case is when we have a sorted array (terminates if no swaps are made)</li>
<li>The worst case is when we have a reverse sorted array (we perform
<p class="equation" style="margin-top: -5px">n + (n - 1) + (n - 2) + ... = n<sup>2</sup></p>
comparisons)</li>
<li>Even though Cocktail Shaker Sort has the same big-O as Bubble Sort, it is still faster; one
case where it significantly outperforms Bubble Sort is when we have a sorted array, except
for the last element which is the smallest, for example [2, 3, 4, 5, 6, 7, 8, 9, 1]</li>
</ul>
</div>
</div>
</div> <!-- mainContent -->
<div id="footer">
<p><a href="index.html">Return to Home Page</a></p>
</div>
</div><!-- container -->
</body>
</html>