9. BUBBLE SORT

The given array is arr = {3,4,5,2,1}. The number of iterations in bubble sort and selection sort respectively are,
5 and 4
4 and 4
2 and 4
2 and 5
The given array is arr = {1,2,3,4,5}. (bubble sort is implemented with a flag variable)The number of iterations in selection sort and bubble sort respectively are,
5 and 4
1 and 4
4 and 1
0 and 4
What will be the recurrence relation of the code of recursive bubble sort?
T(n) = 2T(n/2) + n
T(n) = T(n-1) + n
T(n) = T(n-1) + 1
T(n) = T(n/2) + n
Which of the following sorting algorithm is stable?
Selection Sort      
Insertion Sort      
Bubble Sort      
Heap Sort      
What is the average case complexity of bubble sort?
O(n2)
O(n)
O(nlogn)
O(logn)
What is the best time complexity of bubble sort?
NlogN
N(logN)^2
N
N^2
Assume that we use Bubble Sort to sort n distinct elements in ascending order. When does the best case of Bubble Sort occur?
When elements are sorted in ascending order
When elements are sorted in descending order
When elements are not sorted by any order
There is no best case for Bubble Sort. It always takes O(n*n) time
The number of swappings needed to sort the numbers 8, 22, 7, 9, 31, 5, 13 in ascending order, using bubble sort is
11
12
13
10
Which of the following is not an advantage of optimised bubble sort over other sorting techniques in case of sorted elements?
It is faster
Detects whether the input is already sorted
Consumes less memory
Consumes less time
Select the appropriate code that performs bubble sort.
"for(int j=arr.length-1; j>=0; j++) { for(int k=0; k arr[k+1]) { int temp = arr[k]; arr[k] = arr[k+1]; arr[k+1] = temp; } } }"
"for(int j=arr.length; j>=0; j--) { for(int k=0; k>j; k++) { if(arr[k] > arr[k+1]) { int temp = arr[k]; arr[k] = arr[k+1]; arr[k+1] = temp; } } }"
"for(int j=arr.length-1; j>=0; j--) { for(int k=0; k arr[k+1]) { int temp = arr[k]; arr[k] = arr[k+1]; arr[k+1] = temp; } } }"
"for(int j=arr.length; j>=0; j--) { for(int k=0; k
0
{"name":"9. BUBBLE SORT", "url":"https://www.quiz-maker.com/QQNHD6T4","txt":"The given array is arr = {3,4,5,2,1}. The number of iterations in bubble sort and selection sort respectively are,, The given array is arr = {1,2,3,4,5}. (bubble sort is implemented with a flag variable)The number of iterations in selection sort and bubble sort respectively are,, What will be the recurrence relation of the code of recursive bubble sort?","img":"https://www.quiz-maker.com/3012/images/ogquiz.png"}
Powered by: Quiz Maker