Bubble Sort
1. How many iterations of the outer and inner loops will it take to sort the following array using the optimized algorithm?
A = [-4, -9, -1, 8, -9, 4]
A = [-4, -9, -1, 8, -9, 4]
2. Consider the following array:
A = [8, 7, -2, 4, 1]
Which of the following will represent the array after the 3rd iteration of the algorithm (assume ascending order sort)?
A = [8, 7, -2, 4, 1]
Which of the following will represent the array after the 3rd iteration of the algorithm (assume ascending order sort)?
3. Consider the following array:
A = [8, 7, -2, 4, 1]
How many swaps occur in the 1st iteration of the outer loop?
A = [8, 7, -2, 4, 1]
How many swaps occur in the 1st iteration of the outer loop?
4. Consider the following array:
A = [-10, 100, -1000, 2, 0, -1]
How many iterations of the outer loop will it take to sort this array as per the optimized bubble sort?
A = [-10, 100, -1000, 2, 0, -1]
How many iterations of the outer loop will it take to sort this array as per the optimized bubble sort?