Aspire's Library

A Place for Latest Exam wise Questions, Videos, Previous Year Papers,
Study Stuff for MCA Examinations - NIMCET

Previous Year Question (PYQs)



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





Solution

The numbers are in the range

$0$ to $n^2-1$

Using radix sort with base $n$, each number can be represented using $2$ digits.

Radix sort takes

$O(d(n+b))$

Here,

$d=2$ and $b=n$

So,

$O(2(n+n))=O(n)$

Hence, the best running time is $O(n)$.



Online Test Series,
Information About Examination,
Syllabus, Notification
and More.

Click Here to
View More


Online Test Series,
Information About Examination,
Syllabus, Notification
and More.

Click Here to
View More

Ask Your Question or Put Your Review.

loading...