Bubble Sort

  • May 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Bubble Sort as PDF for free.

More details

  • Words: 116
  • Pages: 1
package br.edu.unicapital.Ordenacao; public class Bubble { private int numeros []; public void setNumeros (int [] vetor){ // capitura o vetor a ordenar numeros = vetor; } private int [] getNumeros () { return numeros; } public int [] ordenado () { // retorna o vetor ordenado bubbleSort(getNumeros()); return getNumeros(); }

}

private void bubbleSort(int v []) { boolean trocou = true; int troca; System.out.println(); System.out.println("Valores ordenados pelo Bubble: "); while (trocou == true) { trocou = false; for (int i = 0; i < v.length - 1; i++) { if (v[i] > v[i + 1]) { troca = v[i]; v[i] = v[i + 1]; v[i + 1] = troca; trocou = true; } } } }

Related Documents

Bubble Sort
May 2020 17
Bubble Sort
May 2020 22
Bubble Sort
June 2020 8
Bubble Sort With Flag
April 2020 16
Parallel Bubble Sort
May 2020 18