COSC 130: Data Structures
Sorting Algorithms
Bubble Sort Demonstration Instructions:
Click on a larger tile to move it to the right.
Complexity Analysis
Best/Average Case: O(nlogn)O(nlog n)O(nlogn) when the pivot divides the array into two nearly equal parts.
Worst Case: O(n^2)O(n^2)O(n^2) when the pivot is always the smallest or largest element.
Space Complexity: O(logn)O(log n)O(logn) for recursive stack calls.