metodos de ordenamiento 2

28
METODOS DE ORDENAMIENTO CAZTELDARY MARTINEZ PEDRAZA ANGELA MONTILLA MIGUEL ANGEL CASTAÑEDA

Upload: angela-montilla

Post on 13-Apr-2017

384 views

Category:

Education


0 download

TRANSCRIPT

METODOS DE ORDENAMIENTO

METODOS DE ORDENAMIENTO

CAZTELDARY MARTINEZ PEDRAZAANGELA MONTILLAMIGUEL ANGEL CASTAEDA

METODOS DE ORDENAMIENTO BURBUJAEn este mtodo la informacin ingresa de forma desorganizada; lo que realiza este ordenamiento es que vector mueve el elemento mayor hasta la ultima casilla esto se realizara en la siguiente manera:

ndice cero del vector a acomoda este elemento hasta la ultima posicin para que de forma escalada se organiza de mayor a menor

PROCEDIMIENTO

Como lo muestra la siguiente grfica en la casilla 0 correspondiente a seis que es el ordenado paso a la ultima posicin y se observa que esta secuencia traslada el valor a la primera posicin.Este proceso seguir as hasta que halla ordenado todas las casillas del vector.Una de las desventaja de este mtodo es que hace duplicidad de la organizacin cuando esto ya no es necesario.

ALGORITMO BURBUJA

Diagrama de flujo Mtodo de burbuja y/o intercambio

SIMULACION//METODO BURBUJA ESTE CODIGO PERMITE ORDENAR UNA SECUENTCIA DE NOMBRES ALFABETICAMENTE//DE ACUERDO AL TAMAO QUE QUERAMOS TENER

import java.util.*;class Burbuja5 {

public static void main(String[] args) { // Valores que tiene el array A desordenado. Scanner tecla = new Scanner(System.in); Scanner key = new Scanner(System.in); int tam; System.out.println("ingrese tamano"); tam = tecla.nextInt(); String[] A= new String[tam]; for(int i=0; i 0 && a[--rightCursor] > pivot); if(leftCursor >= rightCursor){ break; }else{ swap(leftCursor, rightCursor); } } swap(leftCursor, right); return leftCursor; }

SIMULACION// Metodo para realizar el cambio de las posiciones comparadas public static void swap(int left,int right){ int temp = a[left]; a[left] = a[right]; a[right] = temp; } public static void printArray(){ for(int i : a){ System.out.print(i+" "); } } public static int[] getArray(){ int size=10; int []array = new int[size]; int item = 0; for(int i=0;i