-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshellSort.html
More file actions
124 lines (120 loc) · 6.47 KB
/
shellSort.html
File metadata and controls
124 lines (120 loc) · 6.47 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://code.jquery.com/jquery-3.6.0.min.js"
integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"
integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous">
</script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"
integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<script src="https://kit.fontawesome.com/00a4711f34.js" crossorigin="anonymous"></script>
<!-- -->
<link rel="stylesheet" type="text/css" href="style.css">
<!-- -->
<script src="ShellSort.js"></script>
<title>Shell Sort</title>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-dark d-flex align-items-center">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent"
aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id='navbarSupportedContent'>
<ul class='navbar-nav mr-auto'>
<li class='nav-item'><a class="navbar-brand text-white pr-2" href="#"
onclick="window.open('bubbleSort.html','_self');">Bubble Sort</a></li>
<li class='nav-item'><a class="navbar-brand text-white pr-2" href="#"
onclick="window.open('quickSort.html','_self');">Quick Sort</a></li>
<li class='nav-item'><a class="navbar-brand text-white pr-2" href="#"
onclick="window.open('heapSort.html','_self');">Heap Sort</a></li>
<li class='nav-item'><a class="navbar-brand text-white pr-2" href="#"
onclick="window.open('insertionSort.html','_self');">Insertion Sort</a></li>
<li class='nav-item'><a class="navbar-brand text-white pr-2" href="#"
onclick="window.open('shellSort.html','_self');">Shell Sort</a></li>
</ul>
<button type="button" class="btn btn-primary ml-4" onclick='limparRelatorio();'>Limpar
relatório</button>
</div>
</nav>
<div class='micro'>
<div class='container-fluid'>
<div class='row'>
<div class='col-sm-2'>
<div class='overflow'>
<table class="table table-borderless" id='tabelaRandomMicro'>
<thead>
<tr>
<th scope="col">Qtd</th>
<th scope="col">Números</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
<div class='col-sm-2'>
<div class='overflow'>
<table class="table table-borderless" style='width:200px' id='tabelaOrdenadaMicro'>
<thead id='headFixed'>
<tr>
<th>Qtd</th>
<th>Ordenados</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
<div class='col mt-3'>
<div class='row'>
<div class='col-sm-4'>
<input type="text" class="form-control" id='numero' placeholder="Números">
</div>
<div class='col-sm-2'>
<button type="button" class="btn btn-primary" onclick='criaNumero();'>Criar
Lista</button>
</div>
<div class='col-sm-2 offset-md-2' id='botaoOrdena'>
<button type="button" class="btn btn-primary ml-4" onclick='shellSort(shuffledArray);'>Ordenar
Lista</button>
</div>
</div>
<div class='row'>
<div class='col mt-5' style='font-family:candara;font-size:16px'>
<b>É um refinamento do método de inserção direta. O algoritmo difere do método de inserção direta pelo fato de no lugar de considerar o array a ser ordenado como um único segmento, ele considera vários segmentos sendo aplicado o método de inserção direta em cada um deles. Basicamente o algoritmo passa várias vezes pela lista dividindo o grupo maior em menores. Nos grupos menores é aplicado o método da ordenação por inserção.
A ordenação Shell utiliza a quebra sucessiva da sequência a ser ordenada e implementa a ordenação por inserção na sequência obtida. Devido a sua complexidade possui excelentes desempenhos em N muito grandes, inclusive sendo melhor que o Merge Sort.
</b>
</div>
</div>
<div class='row'>
<div class='col mt-5'>
Exemplo:<br>
12, 43, 1, 6, 56, 23, 52, 9<br>
<b>12</b>, 43, <b>1</b>, 6, 56, 23, 52, 9<br>
1, <b>43</b>, 12, <b>6</b>, 56, 23, 52, 9<br>
1, 6, 12, 43, <b>56</b>, 23, <b>52</b>, 9<br>
1, 6, 12, <b>43</b>, 52, 23, 56, <b>9</b><br>
1, 6, <b>12</b>, <b>9</b>, 52, 23, 56, 43<br>
1, 6, 9, 12, <b>52</b>, <b>23</b>, 56, 43<br>
1, 6, 9, 12, 23, 52, <b>56</b>, <b>43</b><br>
1, 6, 9, 12, 23, <b>52</b>, <b>43</b>, 56<br>
1, 6, 9, 12, 23, 43, 52, 56<br>
Em negrito estão os números trocados na atual iteração.
</div>
</div>
</div>
<div class='col-md-4 ml-5'>
<p id='relatorio'></p>
</div>
</div>
</div>
</div>
</body>
</html>