• retagged by
1,127 views
0 0 votes

Which one of the following algorithms cannot sort $n$ numbers in $O(n)$ comparisons?

  1. Counting sort
  2. Radix sort
  3. Heap sort
  4. Bucket sort

2 Answers

0 0 votes

Correct Answer : C

Sorting algorithms can be broadly classified based on whether they are comparison-based or non-comparison-based.

1. Comparison-Based Sorting Algorithms

These algorithms must compare elements to determine their order. The best possible time complexity for comparison-based sorting is O(nlog⁡n).
Heap Sort is a comparison-based sorting algorithm with a worst-case time complexity of O(nlog⁡n), so it cannot sort numbers in O(n)comparisons.

2. Non-Comparison-Based Sorting Algorithms

These algorithms do not rely on element-wise comparisons and can achieve linear time complexity O(n) under certain conditions:

  • Counting Sort: O(n+k), works efficiently when the range of values k is not too large.
  • Radix Sort: O(nk), where k is the number of digits in the largest number.
  • Bucket Sort: O(n) on average when input is uniformly distributed.
Answer:
Position:
Show:

Related questions

0 0 votes
1 1 answer
621
621 views
admin asked Jan 5, 2019
621 views
Which of the following is not a stable sorting algorithm in its typical implementation?Merge sortBubble sortQuick sortInsertion sort
0 0 votes
1 1 answer
563
563 views
admin asked Jan 5, 2019
563 views
The recurrence equation $T(n) = T(\sqrt{n}) + O(1)$ has the following asymptotic solution:$T(n) = O(\sqrt{n})$$T(n) = O(\log n)$$T(n) = O(n^{1/\log n})$$T(n) = O(\log \lo...
0 0 votes
0 0 answers
452
452 views
admin asked Jan 5, 2019
452 views
The Adjacency matrix of a directed graph $\text{G}$ is given below.$\begin{array} {} & a & b & c & d & e & f & g & h & i \\ a & 0 & 1 & 0 & 0 & 0 & 0 & 1 & 0 & 0 \\ b & ...
0 0 votes
1 1 answer
863
863 views
admin asked Jan 5, 2019
863 views
An unordered list contains $n$ distinct elements. The number of comparisons to find an element in the list that is larger than the second minimum in the list is$\Theta(n ...