941 views
0 votes
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 votes
1 votes

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

Related questions

1.7k
views
1 answers
1 votes
PriDix asked Feb 26, 2017
1,744 views
A machine takes 200 second to sort 200 names, using bubble sort . In 800 seconds , it can approximately sort how many names?
568
views
1 answers
0 votes
Bharani Viswas asked May 17, 2016
568 views
m trying to understand a few sorting algorithms, but I'm struggling to see the difference in the bubble sort and insertion sort algorithm.in a particular case where the elements are completly sorted
168k
views
1 answers
16 votes
worst_engineer asked Aug 2, 2015
167,756 views
1. The number of swappings needed to sort the numbers: 8, 22, 7, 9, 31, 19, 5, 13 in ascending order using bubble sort is-(a) 11 (b) 12(c) 13 ... pass and check the swappings. But , it takes too much time.Is there any shortcut possible ?
5.7k
views
1 answers
2 votes
Mak Indus asked Dec 18, 2018
5,656 views
How many passes of bubble sort are required to sort the following sequence (Pass is counted only when at least one swap is performed in the bubble sort pass)? ... (d) 3I am getting ans as 3 but given answer in 4. please verify it