Question
Create a bubble sort method, called bubbleSrt(). This method will sort the array passed to it as a parameter and will display the results of
Create a bubble sort method, called bubbleSrt(). This method will sort the array passed to it as a parameter and will display the results of every pass through the bubble sort. The results should show the bubble sort should sort the highest values appearing on the right first and then working on down towards the left.
The main() method is given below. Use this method as is, making no modifications to it.
public class BubbleSortAssignment {
public static void main(String[] args){
BubbleSort bsrt = new BubbleSort();
int maxSize = 16;
int [ ] arr = new int [maxSize];
for(int j=0; j { int n = (int)(java.lang.Math.random()*99); arr[j] = n; }for (int index = 0; index System.out.print(arr[index] + " "); System.out.println(" "); long start = System.nanoTime(); bsrt.bubbleSrt(arr); long end = System.nanoTime(); System.out.println(" The time required to do the sort was " + (end - start) + " nanoseconds"); } } The results should look like this picture:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started