• edited by
3,254 views
0 0 votes

Given an array where numbers are in range from 1 to n6 , which sorting algorithm can be
used to sort these number in linear time?
A. Not possible to sort in linear time
B: Counting Sort
C: Radix Sort
D. Quick Sort

1 Answer

2 2 votes
Radix sort is correct answer

radix sort complexity =O(d(n+b))

now maximum no is $n^{6}$

so lets take base n  so digit in maximum no is $log_{n}(n^{6}-1) =6$

and base=n

so the complexity is O(6(n+n))=O(2n)=O(n)
Position:
Show:

Related questions

1 1 vote
1 1 answer
149
149 views
GO Classes asked Aug 25
149 views
Let $P$ be the problem of sorting $n\geq1$ elements using only comparisons.Consider the class of all comparison-based algorithms that correctly solve $P$.What is the asym...
0 0 votes
1 answers 1 answer
903
903 views
Mrityudoot asked Mar 7, 2024
903 views
For flag based approach in Bubble sort we can check first by a flag if the list is sorted or not in O(n), and if it is sorted, then no need to sort and the operation ends...
0 0 votes
2 answers 2 answers
1.3k
1.3k views
_Madhuri asked Oct 9, 2021
1,310 views
The complexity of comparison based sorting algorithm is (nlogn) .How?
0 0 votes
0 0 answers
464
464 views