Bubble Sort

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

Explanation

Explanation

Explanation

Explanation

Explanation

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

Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

3. How do we check if our array is sorted in order to preemptively stop the optimized algorithm?
Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

Explanation