GATE CSE
First time here? Checkout the FAQ!
x
+1 vote
68 views

I answered this as $O(n^2)$ considering the question asks for best worst case of all inplace sorting algorithms.

asked in Algorithms by Boss (8.3k points)   | 68 views
quetion ask best case for any inplace sorting algorithm . Bubble sort will take O(n).

1 Answer

0 votes

O(n) is right 

BEST CASE OF INSERTION SORT

The best case input is an array that is already sorted. In this case insertion sort has a linear running time (i.e., O(n)). During each iteration, the first remaining element of the input is only compared with the right-most element of the sorted subsection of the array.

answered by Active (1.2k points)  

Related questions

+6 votes
2 answers
1
asked in Algorithms by srestha Veteran (49.6k points)   | 231 views
+1 vote
1 answer
2
asked in Algorithms by jenny101 Active (1.2k points)   | 60 views
0 votes
2 answers
3
Top Users Jan 2017
  1. Debashish Deka

    7906 Points

  2. Habibkhan

    4736 Points

  3. Vijay Thakur

    4474 Points

  4. sudsho

    4318 Points

  5. saurabh rai

    4200 Points

  6. Arjun

    3638 Points

  7. Bikram

    3494 Points

  8. santhoshdevulapally

    3470 Points

  9. GateSet

    3228 Points

  10. Sushant Gokhale

    3116 Points

Monthly Topper: Rs. 500 gift card

18,944 questions
23,897 answers
52,113 comments
20,213 users