Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6a91a62

Browse files
author
javiluli
committed
Nuevo Algoritmo Sort SHELL
1 parent e5b4130 commit 6a91a62

File tree

5 files changed

+50
-3
lines changed

5 files changed

+50
-3
lines changed

‎README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ java -jar ordenacionVisual.jar
3131
- Quick
3232
- Radix LSD (base 4)
3333
- Selection
34+
- Shell
3435

3536
### Bubble optimized Sort
3637

‎ordenacionVisual.jar

4.97 MB
Binary file not shown.

‎src/Ordenar/Algoritmos/Shell.java

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package Ordenar.Algoritmos;
2+
3+
import Ordenar.AdicionalesSorts;
4+
import Ordenar.ISort;
5+
import Principal.DibujarGraficos;
6+
import Principal.Main;
7+
8+
public class Shell extends AdicionalesSorts implements ISort {
9+
10+
public Shell(Main m, int[] n) {
11+
this.m = m;
12+
sort(n);
13+
}
14+
15+
@Override
16+
public void sort(int[] n) {
17+
setInicio(System.currentTimeMillis());
18+
int increment = n.length / 2;
19+
while (increment > 0) {
20+
for (int i = increment; i < n.length; i++) {
21+
int j = i;
22+
int temp = n[i];
23+
while (j >= increment && n[j - increment] > temp) {
24+
n[j] = n[j - increment];
25+
j = j - increment;
26+
m.updateAnimaciones();
27+
}
28+
n[j] = temp;
29+
}
30+
if (increment == 2) {
31+
increment = 1;
32+
} else {
33+
increment *= (5.0 / 11);
34+
}
35+
}
36+
DibujarGraficos.finSort = true;
37+
}
38+
}

‎src/Ordenar/FinSort.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ public void sort(int[] n) {
1515
for (int i = 0; i < n.length; i++) {
1616
DibujarGraficos.mismo = i + 1;
1717
DibujarGraficos.anterioresMismo = i;
18-
m.updateAnimacionesSinTiempo();
18+
m.updateAnimacionesSoloDelaFijo();
1919
}
2020
DibujarGraficos.finSort = false;
21-
m.updateAnimacionesSinTiempo();
2221
}
2322
}

‎src/Principal/Main.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,12 @@
4141
import Ordenar.Algoritmos.Quick;
4242
import Ordenar.Algoritmos.RadixLSD;
4343
import Ordenar.Algoritmos.Selection;
44+
import Ordenar.Algoritmos.Shell;
4445

4546
public class Main extends AdicionalesSorts {
4647
// NOMBRES DE LOS ALGORITMOS
4748
final String[] nombreAlgoritmos = { "Bubble", "Bubble Optimized", "Cocktail", "Cycle", "Gnome", "Heap", "Insertion",
48-
"Merge", "Odd Even", "Pancake", "Pigeonhole", "Quick", "Radix LSD", "Selection" };
49+
"Merge", "Odd Even", "Pancake", "Pigeonhole", "Quick", "Radix LSD", "Selection", "Shell" };
4950
// DISEÑO GRAFICO DE LAS ANIMACIONES
5051
final static String[] nombreGrafico = { "Escalera", "Piramide horizontal", "Pixel", "Circulo", "Circunferencia",
5152
"Espiral" };
@@ -464,6 +465,9 @@ public void menuSorting() {
464465
case 13:
465466
sorts = new Selection(mainApp, barras.arrayPrincipal);
466467
break;
468+
case 14:
469+
sorts = new Shell(mainApp, barras.arrayPrincipal);
470+
break;
467471
default:
468472
barras.desordenarArray();
469473
break;
@@ -507,6 +511,11 @@ public void updateAnimacionesSinTiempo() {
507511
panelBarras.repaint();
508512
Delay.delay();
509513
}
514+
515+
public void updateAnimacionesSoloDelaFijo() {
516+
panelBarras.repaint();
517+
Delay.delay(1);
518+
}
510519
// ---------------------------------------------------------------------------------------------
511520

512521
/**

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /