This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class Sum { | |
static Scanner sc = new Scanner(System.in); | |
public static void main(String[] args) { | |
int firstNumber; | |
int secondNumber; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class ArrayAverage { | |
public static void main(String[] args) { | |
int arraySize = 0; | |
float[] array; | |
float average = 0; | |
boolean validArraySize = false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
import java.util.Arrays; | |
public class ArrayConcatenation { | |
static Scanner sc = new Scanner(System.in); | |
static int[] arrayOne; | |
static int[] arrayTwo; | |
static int[] finalArray; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Arrays; | |
import java.util.Scanner; | |
public class ArrayReverse { | |
static int arraySize; | |
public static void main(String[] args) { | |
int[] array; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package engineer.davidauza; | |
import java.text.DecimalFormat; | |
import java.text.NumberFormat; | |
import java.util.Locale; | |
public class Main { | |
public static void main(String[] args) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
countingSort(arreglo, tamañoDelArreglo) | |
max <- encontrar el número mayor en el arreglo original | |
inicializar el nuevo arreglo con ceros en él | |
para j <- 0 hasta tamañoDelArreglo | |
encontrar el total de apariciones de cada elemento único y guardar la cuenta en | |
índice j en el nuevo arreglo | |
para i <- 1 hasta max | |
encontrar el acumulado y almacenarlo en el nuevo arreglo | |
para j <- tamañoDelArreglo descendente hasta 1 | |
reubicar los elementos en arreglo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
radixSort(arreglo) | |
d <- número máximo de dígitos en el elemento más grande | |
crear de buckets de tamaño 0-9 | |
for i <- hasta d | |
ordenar los elementos de acuerdo con los dígitos del lugar usando counting sort | |
countingSort(arreglo, tamañoDelArreglo) | |
max <- encontrar el número mayor en el arreglo original | |
inicializar el nuevo arreglo con ceros en él | |
para j <- 0 hasta tamañoDelArreglo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Implementación algoritmo Counting Sort. | |
import java.util.Arrays; | |
class Main { | |
// Este método realiza el ordenamiento de un arreglo utilizando el algoritmo CountingSort. | |
private static int[] countSort(int[] arreglo) { | |
int tamanoDelArreglo = arreglo.length; | |
int[] arregloResultante = new int[tamanoDelArreglo]; | |
// Se obtiene el número mayor del arreglo. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Implementación algoritmo Radix Sort. | |
import java.util.Arrays; | |
class Main { | |
// Este método utiliza el algoritmo Radix Sort para ordenar un arreglo. | |
private static int[] radixSort(int[] arreglo) { | |
int max = obtenerMaximo(arreglo); | |
for(int i = 1; max / i > 0; i *= 10) { | |
arreglo = countSort(arreglo); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bucketSort() | |
crea N buckets en cada uno de los cuales pueden contener un rango de valores | |
for todos los buckets | |
Se inician en cada bucket con 0 valores | |
for todos los buckets | |
Ponen elementos dentro del buckets comparando el rango | |
for todos los buckets | |
Se ordenan los bucket en cada elemento reuniendo los elementos en cada bucket | |
fin del bucket sort |
OlderNewer