Bubble Sort

1. How many iterations of the outer loop are needed by the optimized Bubble Sort algorithm when the input array of size N is already sorted?

Explanation

Explanation

Explanation

Explanation

Explanation

2. How many comparisons (equal to the number of iterations of the inner loop) are required in the next iteration after T iterations of the outer loop in the optimized Bubble Sort algorithm? The array size is N.

Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

3. How does the optimized Bubble Sort algorithm check whether it can stop early because the array is already sorted?
Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

4. What is the main advantage of the optimized Bubble Sort over the regular Bubble Sort?
Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

5. For an array of N elements, how many comparisons are made in the first pass of the optimized Bubble Sort?

Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

6. Suppose the optimized Bubble Sort performs T complete passes without stopping. How many largest elements are guaranteed to be in their final positions after those T passes?

Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

7. Consider A = [1, 2, 3, 4]. What happens during the first pass of optimized Bubble Sort in ascending order?
Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

8. Which variable or mechanism is commonly used in an optimized Bubble Sort implementation to detect whether a pass made any swaps?
Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

9. If an optimized Bubble Sort is applied to a reverse-sorted array of N elements, which statement is generally true?
Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

Explanation