Skip to the content.
Home This week's review ticket Replit code team repository Tech Talks Lecture Notes

Bubble Sorting Algorithms analysis:

Terms to know:

//traverse and repeat traversing array
        for (int i = 0; i < array.size() - 1; i++) {
            for (int j = array.size() - 1; j > i; j--) {
                //compare elements
                if (array.get(j - 1) > array.get(j)) {
                    //Swap
                    int temp = array.get(j - 1);
                    array.set(j -1, array.get(j));
                    array.set(j, temp);
                }
            }
        }

Big O complexity:

Analytics:

Overall, around 6.1 million to 6.3 million swaps were made from the 12 tests

12497500 comparisons were made each test

total time of bubble sort was 1.67 seconds

average time of bubble sort was .14 seconds

Highest time was .236 seconds

Lowest time was .124 seconds