Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:

image text in transcribed

sptrosasi

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Time Series Databases New Ways To Store And Access Data

Authors: Ted Dunning, Ellen Friedman

1st Edition

1491914726, 978-1491914724

More Books

Students also viewed these Databases questions

Question

Explain the meaning of significant risks and rewards of ownership.

Answered: 1 week ago