What is Bubble Sort?
A
A sorting algorithm that repeatedly swaps adjacent elements if they are in the wrong order B
A sorting algorithm that divides the array into subarrays C
A sorting algorithm that uses a heap data structure D
A non-comparison based sorting algorithm
Analysis & Theory
Bubble Sort repeatedly compares adjacent elements and swaps them.
What is the worst-case time complexity of Bubble Sort?
A
O(n log n) B
O(n) C
O(n^2) D
O(log n)
Analysis & Theory
In the worst case, Bubble Sort requires n^2 comparisons and swaps.
Which scenario is the best case for Bubble Sort?
A
Array sorted in reverse order B
Array already sorted C
Array with all elements equal D
Array with random elements
Analysis & Theory
If the array is already sorted, Bubble Sort finishes in O(n) time.
Bubble Sort is considered which type of sorting algorithm?
A
Divide and conquer B
Comparison-based C
Counting-based D
Hash-based
Analysis & Theory
Bubble Sort is a comparison-based algorithm.
How does Bubble Sort detect if the array is already sorted?
A
By counting inversions B
By using a swapped flag C
By checking the sum of elements D
It cannot detect it
Analysis & Theory
Bubble Sort uses a swapped flag to see if any swaps were made in a pass.
What is the average-case time complexity of Bubble Sort?
A
O(n) B
O(log n) C
O(n log n) D
O(n^2)
Analysis & Theory
On average, Bubble Sort performs O(n^2) operations.
Is Bubble Sort a stable sorting algorithm?
A
Yes B
No C
Depends on implementation D
Only for numeric data
Analysis & Theory
Bubble Sort is stable because it does not change the relative order of equal elements.
How many passes are required in Bubble Sort to guarantee the array is sorted?
A
n B
n-1 C
log n D
n^2
Analysis & Theory
At most n-1 passes are required to fully sort the array.
Which of these statements about Bubble Sort is FALSE?
A
It is easy to implement B
It is efficient for large datasets C
It can be optimized by stopping early if no swaps are made D
It compares adjacent elements
Analysis & Theory
Bubble Sort is not efficient for large datasets.
What is a key operation in Bubble Sort?
A
Merging sorted subarrays B
Swapping adjacent elements C
Selecting a pivot D
Building a heap
Analysis & Theory
Bubble Sort repeatedly swaps adjacent elements if they are in the wrong order.