0
$\begingroup$

I'm reading the CLRS book and there is a statement

for instance, the running time of insertion sort is not $\Omega(n^2)$, since there exists an input for which insertion sort runs in $\Theta(n)$ time (e.g., when the input is already sorted). It is not contradictory, however, to say that the worst-case running time of insertion sort is $\Omega(n^2)$, since there exists an input that causes the algorithm to take $\Omega(n^2)$ time.

I just want to clarify some things to find that I understand this correctly. So does the last statement mean that the worst-case running time can't be linear function as we have $\Omega(n^2)$ for this? And another, can we say that the best case running time of insertion sort is $O(n)?$

$\endgroup$
  • 1
    $\begingroup$ Yes for both. $\quad$ $\endgroup$ – Apass.Jack Jun 11 at 23:18
  • 2
    $\begingroup$ I'm voting to close this question as off-topic because besides answering yes, there is not much else to say. $\endgroup$ – Apass.Jack Jun 11 at 23:26
  • $\begingroup$ @Apass.Jack thanks for the answer. Sorry that the question is off-topic, but for me it was important to get a confirmation that I understand everything correctly to be able to move on. If cs.stackexchange is not a good place for such questions, could you please recommend where it's more appropriate to ask them? $\endgroup$ – E. Shcherbo Jun 12 at 9:29
  • $\begingroup$ Sorry if my comment confused you. It is on-topic in the sense that the question is about algorithm analysis and asymptotics. I understand it may be important for you to get a confirmation. However, there is not much to say in an answer besides a confirmation that you have applied definitions correctly. So, it is unlikely that an answer will provide extra values for future readers on this common topic where we must have many many answers already. For this reason, we would like to close the question by labeling it "off-topic" technically. $\endgroup$ – Apass.Jack Jun 12 at 9:46
  • $\begingroup$ It is rather a drawback of this site that there is no option to close a question on the ground that "an answer is unlikely to provide extra values". You can also read this and this that explains why a question of the form "is X correct?" may get closed. $\endgroup$ – Apass.Jack Jun 12 at 9:53