Ordenação Pelo Método Bolha
Publicado por Antonio Delvair Zaneti / NossoClick.com (última atualização em 28/07/2017)
[ Hits: 3.458 ]
Homepage: www.nossoclick.com
Neste arquivo realizaremos a ordenação pelo método bolha, inserindo aleatoriamente 1000 elementos e calculando o tempo utilizado na ordenação.
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package programacaojava;
import java.io.*;
/**
*
* @author azaneti
*/
public class ProgramacaoJava {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws IOException {
// TODO code application logic here
int quantidade = 10000;
int[] vetor = new int[quantidade];
for (int i=0; i<vetor.length; i++)
{
vetor [i]=(int)(Math.random()*quantidade);
}
long tempoInicial = System.currentTimeMillis();
bubbleSort (vetor);
long tempoFinal = System.currentTimeMillis();
System.out.println("Executado em " + (tempoFinal - tempoInicial)+ "ms");
}
private static void bubbleSort(int vetor[])
{
boolean troca = true;
int aux;
while(troca){
troca=false;
for (int i=0; i<vetor.length -1; i++)
{
if (vetor[i]>vetor[i+1]){
aux = vetor[i] ;
vetor[i]=vetor[i+1];
vetor[i+1]=aux;
troca = true;
}
}
}
}
}
Calcular horas faltas de um funcionário
Calculadora básica e simples de entender
Nenhum comentário foi encontrado.
Gentoo binário em 2026: UEFI, LUKS, Btrfs e Systemd
Trabalhando Nativamente com Logs no Linux
Jogando Daikatana (Steam) com Patch 1.3 via Luxtorpeda no Linux
LazyDocker – Interface de Usuário em Tempo Real para o Docker
Usando dracut e dispensando genkernel no Gentoo + LUKS + Btrfs
Curso GRÁTIS: OCS Inventory NG - Do Deploy ao Hardening com foco em Segurança da Informação!
Instalando fontes via script no Nautilus Scripts no Gnome do Debian 13
O que houve com slackware ??? (3)
Pendrive do Ubuntu 24.04 travando ao tentar fazer a instalação dual bo... (5)
erros nos arquivos sources list ubuntu [RESOLVIDO] (3)
Instalar Linux em notebook Sony Vaio VPCEG13EB (7)
VirtualBox no Ubuntu 25.10 sem redimensionam... automatico. (2)









