Quick 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 Quick Sort as PDF for free.

More details

  • Words: 127
  • Pages: 1
package br.edu.unicapital.Ordenacao; public class QuickSort { private int numeros []; public void setNumeros (int [] vetor) { // capitura o vetor a ordenar numeros = vetor; } private int [] getNumeros () { return numeros; } public int[] ordene () { // metodo que retorna o vetor ordenado quickSort(getNumeros(), 0, getNumeros().length-1); return getNumeros(); } private void quickSort(int x[],int iniVet, int fimVet) { int i = iniVet; int j = fimVet; int pivo = x[(iniVet + fimVet) / 2]; do { while(x[i] < pivo){ i++; } while(x[j]> pivo){ j--; } if(i <= j){ int troca = x[i]; x[i] = x[j]; x[j] = troca; i++; j--; } } while(i <= j); if(j > iniVet){ quickSort(x , iniVet, j); } if(i < fimVet){ quickSort(x , i, fimVet); } } }

Related Documents

Quick Sort
May 2020 4
Quick Sort
July 2020 6
Quick Sort
June 2020 6
Quick Sort
May 2020 20
Ex-17 Quick Sort
October 2019 5
Junaid (quick Sort)
April 2020 9