COMPUTER SCIENCE AND ENGINEERING
DATA STRUCTURES
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
|
2, 9, 5, 4, 8, 1
|
|
2, 9, 5, 4, 1, 8
|
|
2, 5, 9, 4, 8, 1
|
|
2, 5, 4, 8, 1, 9
|
Detailed explanation-1: -Bubble Sort is the most basic sorting algorithm, and it operates by periodically exchanging nearby components if they are out of order. This approach is not suited for huge data sets due to its high average and worst-case time complexity. Hence the correct answer is 32, 27, 51, 66, 23, 13, 57, 85.
Detailed explanation-2: -Bubble sort may require (n/2) passes and O(n) comparisons for each pass in the average case. As a result, the average case time complexity of bubble sort is O(n/2 x n) = O(n/2 x n) = O(n/2 x n) = O(n/2 x n) = O (n2).
Detailed explanation-3: -Explanation: Even though the first two elements are already sorted, bubble sort needs 4 iterations to sort the given array.
Detailed explanation-4: -The algorithm needs one whole pass without any swap to know it is sorted.