{ grupo tyrex integrantes: alberto melgar michael lama

27
{ Grupo Tyrex Integrantes: Alberto Melgar Michael Lama

Upload: valentin-belmonte-martin

Post on 02-Feb-2016

223 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: { Grupo Tyrex Integrantes: Alberto Melgar Michael Lama

{Grupo Tyrex

Integrantes:Alberto MelgarMichael Lama

Page 2: { Grupo Tyrex Integrantes: Alberto Melgar Michael Lama

Radix sort

Es un algoritmo de ordenamiento que funciona ordenando un numero en base a sus dígitos. Es de orden (kn), donde k es la cantidad de dígitos que tiene el mayor numero.

Page 3: { Grupo Tyrex Integrantes: Alberto Melgar Michael Lama

Radix sort

LSD MSD

Existen 2 tipos de ordenamiento radix:LSD(Least Significant Digit) y MSD(Most significant Digit)

Page 4: { Grupo Tyrex Integrantes: Alberto Melgar Michael Lama

Radix sortComo funciona?

0

1

2 362

3

4

5

6

7

8

9

Page 5: { Grupo Tyrex Integrantes: Alberto Melgar Michael Lama

Radix sortComo funciona?

0

1

2 362

3

4

5

6 436

7

8

9

Page 6: { Grupo Tyrex Integrantes: Alberto Melgar Michael Lama

Radix sortComo funciona?

0

1 291

2 362

3

4

5

6 436

7

8

9

Page 7: { Grupo Tyrex Integrantes: Alberto Melgar Michael Lama

Radix sortComo funciona?

0

1 291

2 362

3

4

5

6 436

7 487

8

9

Page 8: { Grupo Tyrex Integrantes: Alberto Melgar Michael Lama

Radix sortComo funciona?

0

1 291

2 362

3

4

5

6 436

7 487, 207

8

9

Page 9: { Grupo Tyrex Integrantes: Alberto Melgar Michael Lama

Radix sortComo funciona?

0

1 291

2 362

3 253

4

5

6 436

7 487, 207

8

9

Page 10: { Grupo Tyrex Integrantes: Alberto Melgar Michael Lama

Radix sortComo funciona?

0

1 291

2 362

3 253

4

5

6 436

7 487, 207, 397

8

9

Page 11: { Grupo Tyrex Integrantes: Alberto Melgar Michael Lama

Radix sortComo funciona?

0

1

2

3

4

5

6

7

8

9 291

Page 12: { Grupo Tyrex Integrantes: Alberto Melgar Michael Lama

Radix sortComo funciona?

0

1

2

3

4

5

6 362

7

8

9 291

Page 13: { Grupo Tyrex Integrantes: Alberto Melgar Michael Lama

Radix sortComo funciona?

0

1

2

3

4

5 253

6 362

7

8

9 291

Page 14: { Grupo Tyrex Integrantes: Alberto Melgar Michael Lama

Radix sortComo funciona?

0

1

2

3 436

4

5 253

6 362

7

8

9 291

Page 15: { Grupo Tyrex Integrantes: Alberto Melgar Michael Lama

Radix sortComo funciona?

0

1

2

3 436

4

5 253

6 362

7

8 487

9 291

Page 16: { Grupo Tyrex Integrantes: Alberto Melgar Michael Lama

Radix sortComo funciona?

0 207

1

2

3 436

4

5 253

6 362

7

8 487

9 291

Page 17: { Grupo Tyrex Integrantes: Alberto Melgar Michael Lama

Radix sortComo funciona?

0 207

1

2

3 436

4

5 253

6 362

7

8 487

9 291, 397

Page 18: { Grupo Tyrex Integrantes: Alberto Melgar Michael Lama

Radix sortComo funciona?

0

1

2 207

3

4

5

6

7

8

9

Page 19: { Grupo Tyrex Integrantes: Alberto Melgar Michael Lama

Radix sortComo funciona?

0

1

2 207

3

4 436

5

6

7

8

9

Page 20: { Grupo Tyrex Integrantes: Alberto Melgar Michael Lama

Radix sortComo funciona?

0

1

2 207,253

3

4 436

5

6

7

8

9

Page 21: { Grupo Tyrex Integrantes: Alberto Melgar Michael Lama

Radix sortComo funciona?

0

1

2 207,253

3 362

4 436

5

6

7

8

9

Page 22: { Grupo Tyrex Integrantes: Alberto Melgar Michael Lama

Radix sortComo funciona?

0

1

2 207,253

3 362

4 436, 487

5

6

7

8

9

Page 23: { Grupo Tyrex Integrantes: Alberto Melgar Michael Lama

Radix sortComo funciona?

0

1

2 207,253, 291

3 362

4 436, 487

5

6

7

8

9

Page 24: { Grupo Tyrex Integrantes: Alberto Melgar Michael Lama

Radix sortComo funciona?

0

1

2 207,253, 291

3 362, 397

4 436, 487

5

6

7

8

9

Page 26: { Grupo Tyrex Integrantes: Alberto Melgar Michael Lama

public static void RadixSort(int[] n) { if (n.length == 0) { return; } int[][] np = new int[n.length][2]; int[] q = new int[0x100]; int i, j, k, l, f = 0; for (k = 0; k < 4; k++) { for (i = 0; i < (np.length - 1); i++) { np[i][1] = i + 1; } np[i][1] = -1; for (i = 0; i < q.length; i++) { q[i] = -1; } for (f = i = 0; i < n.length; i++) { j = ((0xFF << (k << 3)) & n[i])>> (k << 3); if (q[j] == -1) { l = q[j] = f;

} else { l = q[j]; while (np[l][1] != -1) { l = np[l][1]; } np[l][1] = f; l = np[l][1]; } f = np[f][1]; np[l][0] = n[i]; np[l][1] = -1; } for (l = q[i = j = 0]; i < 0x100; i++) { for (l = q[i]; l != -1; l = np[l][1]) { n[j++] = np[l][0]; } } } }

Page 27: { Grupo Tyrex Integrantes: Alberto Melgar Michael Lama

public String execute(lista l) {

String[][] mat = new String[10][l.tamano]; for (int i = 0; i < 10; i++) { for (int i2 = 0; i2 < l.tamano; i2++) { mat[i][i2] = ""; }//fin del for }//fin del for String x = ""; int digito = 1; char f = ' '; for (int i = 0; i < obtenerDigito(l); i++) { for (int i2 = 0; i2 < l.tamano; i2++) { System.out.println("i2=" + i2); x = l.getNodo(i2).info.toString(); int h = x.length() - 1; if (i == 0) {

f = x.charAt(h); }//fin del if else { if (h < digito) { f = '0'; }//fin del if else { f = x.charAt(h - digito); }//fin del else }//fin del else switch (f) { case '0': for (int i5 = 0; i5 < l.tamano; i5++) { if ("".equals(mat[0][i5])) { mat[0][i5] = x; break; } }//fin del for break; case '1': for (int i5 = 0; i5 < l.tamano; i5++) { if ("".equals(mat[1][i5])) { mat[1][i5] = x; break; } } break; case '2': for (int i5 = 0; i5 < l.tamano; i5++) { if ("".equals(mat[2][i5])) {

mat[2][i5] = x; break; } } break; case '3': for (int i5 = 0; i5 < l.tamano; i5++) { if ("".equals(mat[0][i5])) { mat[3][i5] = x; break; } } break; case '4': for (int i5 = 0; i5 < l.tamano; i5++) { if ("".equals(mat[0][i5])) { mat[4][i5] = x; break; }//fin del if } break; case '5': for (int i5 = 0; i5 < l.tamano; i5++) { if ("".equals(mat[0][i5])) { mat[5][i5] = x; break; } } break; case '6': for (int i5 = 0; i5 < l.tamano; i5++) { if ("".equals(mat[0][i5])) { mat[6][i5] = x; break; } } break; case '7': for (int i5 = 0; i5 < l.tamano; i5++) { if ("".equals(mat[0][i5])) { mat[7][i5] = x; break; } } break; case '8': for (int i5 = 0; i5 < l.tamano; i5++) { if ("".equals(mat[0][i5])) {

mat[8][i5] = x; break; } } break; case '9': for (int i5 = 0; i5 < l.tamano; i5++) { if ("".equals(mat[0][i5])) { mat[9][i5] = x; break; } } break; }//fin del switch

}//fin del for digito++; lista temp = new lista();

for (int i5 = 0; i5 < 10; i5++) {

for (int i6 = 0; i6 < l.tamano; i6++) {

if (!"".equals(mat[i5][i6])) {

temp.insertar(mat[i5][i6]);

}//fin del if }//fin del for }//fin del for l.liberate(); for (int i5 = 0; i5 < temp.tamano; i5++) {

l.insertar(temp.getNodo(i5).info); }//fin del for for (int i5 = 0; i5 < 10; i5++) { for (int i6 = 0; i6 < l.tamano; i6++) { mat[i5][i6] = ""; }//fin del for }//fin del for }//fin del primer for String ret = ""; for (int i = 0; i < l.tamano; i++) { ret += l.getNodo(i).info.toString() + ","; }//fin del for return ret;

}//fin del metodo