Allan Didier

Bubble Sort

Goals

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

Skills

  • Bubble Sort
  • Wrapper class

Program Details

Create a program that uses the Bubble Sort technique to sort an ArrayList of integers. The program should include the following.
See https://www.geeksforgeeks.org/bubble-sort/ 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.
    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.

Resources

None