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:

Create a bubble sort method, called bubbleSrt(). This method will sort the

sptrosasi

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!