Ordenação Pelo Método Bolha
Publicado por Antonio Delvair Zaneti / CornelioDigital.com (última atualização em 28/07/2017)
[ Hits: 2.950 ]
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; } } } } }
Mensagem usando opção gráfica JOptionPane
Retorno de nomes (com gráficos)
Nenhum comentário foi encontrado.
Atualizar o macOS no Mac - Opencore Legacy Patcher
Crie alias para as tarefas que possuam longas linhas de comando - bash e zsh
Criando um gateway de internet com o Debian
Configuração básica do Conky para mostrar informações sobre a sua máquina no Desktop
Aprenda a criar músicas com Inteligência Artificial usando Suno AI
Instalando e usando o Dconf Editor, o "regedit" para Linux
Como instalar o navegador TOR no seu Linux
Instalando Zoom Client no Ubuntu 24.04 LTS
Remover por completo uma DE (4)
Dificuldade em ler binário (17)
Manjaro Substituindo Ubuntu no Desktop (7)