CJCoding With Joseph
15free / daySign inCreate account

Finish the Bubble Sort Inner Loop

NumberList owns an int array and its size. bubbleSort() already has both of its loops, and a private swap(int i, int j) is written for you. Only the body of the inner loop is missing.

Requirements:
1. Inside the inner loop, compare data[j] with data[j + 1].
2. Call swap(j, j + 1) when the left value is the larger one, so the list ends up in ascending order.

Do NOT write a main method.

Expected Output:

List: 5 1 4 2 8
List: 1 2 4 5 8
5

= newline. The output ends with a newline — print one after the last line.

Hints2 available
Topics:
Data Structures & AlgorithmsSorting
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (sysout, psvm, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.