Escolar Documentos
Profissional Documentos
Cultura Documentos
Códigos Implementados
Metodo BOLHA – Bubble Sort
import java.io.IOException;
}
Projeto e Análise de Algoritmos
Códigos Implementados
Metodo HEAP SORT
n = a.length - 1;
for (int i = n / 2; i >= 0; i--) {
maxheap(a, i);
}
}
largest = left;
} else {
largest = i;
}
largest = right;
}
if (largest != i) {
exchange(i, largest);
maxheap(a, largest);
}
}
exchange(0, i);
n = n - 1;
maxheap(a, 0);
}
}
}
sort(vetor);
System.out.println("\n HeapSort:");
for (int i = 0; i < vetor.length; i++) {
System.out.print(vetor[i] + " ");
}
System.out.println("\n Contador= " + cont);
}
}
Projeto e Análise de Algoritmos
Códigos Implementados
Metodo INSERÇÃO – Insertion Sort
public class Insercao {
int i, j, eleito;
j = i;
return numeros;
}
}
Projeto e Análise de Algoritmos
Códigos Implementados
Metodo QUICK SORT
int i = lowerIndex;
int j = higherIndex;
while (i <= j) {
contador++;
while (array[i] < pivot) {
contador++;
i++;
}
while (array[j] > pivot) {
j--;
contador++;
}
if (i <= j) {
exchangeNumbers(i, j);
i++;
j--;
}
}
if (lowerIndex < j)
quickSort(lowerIndex, j);
if (i < higherIndex)
quickSort(i, higherIndex);
}
sorter.sort(input);
for (int i : input) {
System.out.print(i + " - ");
System.out.print(" ");
}
aux = vetor[i];
vetor[i] = vetor[menor];
vetor[menor] = aux;
}
}
System.out.println("Vetor inicial: \n");
for (int i = 0; i < tamanho; i++) {
System.out.print(" " + meuVetor[i]);
}
selecao(meuVetor);
System.out.println("\n \n Vetor ordenado: \n");
for (int i = 0; i < tamanho; i++) {
System.out.print(" " + meuVetor[i]);
}
}
}