The Gateway to Computer Science Excellence
+3 votes
170 views

Which of the following is best running time to sort $n$ integers in the range $0$ to $n^2-1$?

  1. $O(\text{lg } n)$
  2. $O(n)$
  3. $O(n\text { lg }n)$
  4. $O(n^2)$
in Algorithms by Veteran (424k points)
edited by | 170 views
0
Best case of Insertion/Bubble sort (When Numbers are already sorted).

i.e O(n)
+1
can we sort in lgn time ?  at best it may be O(n)

1 Answer

0 votes

Best time complexity is O(n). 

 

Refer below link for reference 

 

https://www.geeksforgeeks.org/sort-n-numbers-range-0-n2-1-linear-time/

 

 

by (77 points)

Related questions

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
50,648 questions
56,429 answers
195,208 comments
99,921 users