Allan Didier

Bubble Sort


Write a program to sort numbers using the Bubble Sort algorithm.


Program Details

Create a program that uses the Bubble Sort technique to sort an ArrayList of integers. The program should include the following.
See for a more detailed explanation of the Bubble Sort algorithm.

Main Program. Your program should:

    1. Create an ArrayList of 20 random integers from 1 to 100. You will need to use the wrapper class Integer to do this. 
    2. Print the original, unordered array.
    3. Sorts the array of integers using the Bubble sort technique.
    4. Print the ArrayList during each major iteration of sorting to see how the sorting works, i.e. after each iteration of your main outer for loop (for i), not the inner loops (j and k).
    5. Print the final sorted ArrayList.



Bill Barnum’s AP Computer Science A test prep videos