COMPUTER SCIENCE AND ENGINEERING
ALGORITHMS
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
How many passes will it take to sort this data in ascending order, 1, 2, 3, 5, 4.
|
2
|
|
5
|
|
3
|
|
1
|
Explanation:
Detailed explanation-1: -Explanation: Even though the first two elements are already sorted, bubble sort needs 4 iterations to sort the given array.
Detailed explanation-2: -Expert-Verified Answer. 5 interchanges are required to sort 5, 1, 6, 2 4 in ascending order using bubble sort.
Detailed explanation-3: -Time complexity of Merge Sort is O(n*Log n) in all the 3 cases (worst, average and best) as merge sort always divides the array in two halves and takes linear time to merge two halves. It requires equal amount of additional space as the unsorted array.
Detailed explanation-4: -The least number of comparisons needed to sort (order) five elements is 8.
There is 1 question to complete.