Finish the Bubble Sort Inner Loop
easyQuestion 430NumberList 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, so print one after the last line.
Hints2 available
Sign in to use hintsTopics
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.