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?
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.
3. How does the optimized Bubble Sort algorithm check whether it can stop early because the array is already sorted?
4. What is the main advantage of the optimized Bubble Sort over the regular Bubble Sort?
5. For an array of N elements, how many comparisons are made in the first pass of the optimized Bubble Sort?
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?
7. Consider A = [1, 2, 3, 4]. What happens during the first pass of optimized Bubble Sort in ascending order?
8. Which variable or mechanism is commonly used in an optimized Bubble Sort implementation to detect whether a pass made any swaps?
9. If an optimized Bubble Sort is applied to a reverse-sorted array of N elements, which statement is generally true?