First time here? Checkout the FAQ!
+1 vote

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 (9.1k points) 4 64 208 | 107 views
quetion ask best case for any inplace sorting algorithm . Bubble sort will take O(n).

2 Answers

+1 vote

O(n) is right 


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.4k points) 5 17
Best Case complexity of Bubble Sort is O(n).
+1 vote

Bubble sort, as well as Insertion sort both, will give o(n) in its best case: in bubble sort assumption is made that the passes will be stopped on the same instance when the elements are sorted. While in Insertion sort assumption is that the elements are already sorted or almost sorted

answered by Active (1.8k points) 1 4 18

Related questions

+3 votes
0 answers
asked in Algorithms by manu00x Veteran (14.9k points) 6 19 58 | 93 views
0 votes
2 answers

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
Top Users Oct 2017
  1. Arjun

    23338 Points

  2. Bikram

    17048 Points

  3. Habibkhan

    7912 Points

  4. srestha

    6228 Points

  5. Debashish Deka

    5438 Points

  6. jothee

    4968 Points

  7. Sachin Mittal 1

    4772 Points

  8. joshi_nitish

    4286 Points

  9. sushmita

    3964 Points

  10. Rishi yadav

    3794 Points

Recent Badges

Popular Question makhdoom ghaya
Popular Question junaid ahmad
Notable Question learner_geek
Notable Question jothee
Popular Question jothee
Notable Question Jeffrey Jose
Notable Question air1ankit
Nice Question jothee
Verified Human shaleen25
Popular Question jothee
27,290 questions
35,142 answers
33,231 users