• retagged by
551 views
1 1 vote

What could be the best algorithm from the following when the time complexity is measured based bon the number of swaps performed by the sorting algorithm?

1. Selection sort

2.  Insertion sort

3. Bubble sort

4. None of these

1 Answer

1 1 vote
selection sort max n-1 swap

insertion sort max n(n-1)/2 swap

bubble sort max n*(n-1)/2 swap
Position:
Show:

Related questions

4 4 votes
3 3 answers
988
988 views
kallu singh asked Jan 20, 2018
988 views
A certain problem is having an algorithm with the following recurrence relation.\[T(n)=2 \cdot T(\sqrt{n})+n\]How much time would the algorithm take to solve the problem?
1 1 vote
1 1 answer
700
700 views
kallu singh asked Aug 13, 2017
700 views
In the following C function, let n >= m.int gcd(n,m) { if (n%m ==0) return m; n = n%m; return gcd(m,n); }How many recursive calls are made by this function? (A) (logn)?(B...
1 1 vote
1 answers 1 answer
901
901 views
iarnav asked Mar 29, 2018
901 views
*NOTE: I'm not looking to find the Time Complexity, but I'm looking for number of comparisons and the answer is3/2n -2T(n) = 2T(n/2) +2 T(2) = 1T(1) = 0and I'm stuck at t...
1 1 vote
1 1 answer
999
999 views
kallu singh asked Aug 13, 2017
999 views
Q. In Quick sort ,for sorting n element ,the (n/4)th smallest element is selected as pivot using an O(n) time algorithm. What is the worst case tome complexity of the Qu...