This document contains code to sort an integer array using a bubble sort algorithm. The bubble() method takes an integer array as input and iterates through the array, comparing adjacent elements and swapping them if they are out of order. This continues until the entire array is sorted. The main method prompts the user to enter the array length, initializes an array of that length, calls methods to populate and print the array, then sorts the array using bubble() and prints the sorted array.
This document contains code to sort an integer array using a bubble sort algorithm. The bubble() method takes an integer array as input and iterates through the array, comparing adjacent elements and swapping them if they are out of order. This continues until the entire array is sorted. The main method prompts the user to enter the array length, initializes an array of that length, calls methods to populate and print the array, then sorts the array using bubble() and prints the sorted array.
Copyright:
Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online from Scribd
This document contains code to sort an integer array using a bubble sort algorithm. The bubble() method takes an integer array as input and iterates through the array, comparing adjacent elements and swapping them if they are out of order. This continues until the entire array is sorted. The main method prompts the user to enter the array length, initializes an array of that length, calls methods to populate and print the array, then sorts the array using bubble() and prints the sorted array.
Copyright:
Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online from Scribd
Test1 ob=new Test1(); Scanner l=new Scanner(System.in); System.out.println("ingrese la longitud del arreglo:"); int lng=l.nextInt(); int [] B = new int[lng]; ob.lectura(B); //ob.Impresion(B); ob.burbuja(B); ob.Impresion(B); }