← Back to Data Structures & Algorithms
Question 430
Finish the Bubble Sort Inner Loop
Finish the Bubble Sort Inner Loop
NumberList owns an int array and its size.bubbleSort()already has both of its loops, and a privateswap(int i, int j)is written for you. Only the body of the inner loop is missing. Requirements: 1. Inside the inner loop, comparedata[j]withdata[j + 1]. 2. Callswap(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
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.