1,409 views
0 0 votes
Which of the following can make for an improved version of bubble sort?
(A) Traverse the array left to right during odd passes and right to left during even passes, in bubble sort
(B) Divide the array into smaller arrays, apply quick sort on each of the small arrays and the apply bubble sort on the entire array
(C) Store the addresses to be swapped in a separate array and make all the swaps at one go
(D) None of these

1 Answer

1 1 vote

Bubble sort can be improved by using inner loop while required (i.e. swapping element while required) , otherwise inner loop should skip
(A) Doing both way sort is not an efficient solution , As if we do left to right increasing order sorting , then right to left decreasing order.

(B) Though quick sort has time complexity O(n log n) in avg case which is better than bubble sort O(n2), but that is not  needed for getting better version of bubble sort. Actually here we  are using quick sort and then again bubble sort , which is not improving time or space complexity of bubble sort

(C)Swapping in separate array will increase space complexity of bubble sort

So, Answer will be (D)

• edited by
Position:
Show:

Related questions

2 2 votes
2 2 answers
190
190 views
GO Classes asked Aug 12
190 views
Which algorithm-design strategies can reasonably describe Bubble Sort?Greedy Brute force Decrease-and-conquer Divide-and-conquer Dynamic programming
2 2 votes
2 2 answers
148
148 views
GO Classes asked Aug 12
148 views
After the first complete pass of Bubble Sort on an array of size $n$, which element is guaranteed to be in its correct position?The smallest element The largest element A...
2 2 votes
2 2 answers
160
160 views
GO Classes asked Aug 11
160 views
The nontrivial operation involved in the bubble sort is comparing two numbers, i.e., checking the $\texttt{if}$ condition in the inner $\texttt{for}$ loop.How many compar...
1 1 vote
1 1 answer
2.1k
2.1k views
PriDix asked Feb 26, 2017
2,089 views
A machine takes 200 second to sort 200 names, using bubble sort . In 800 seconds , it can approximately sort how many names?