the above mentioned procedure is called counting sort

Also bro how can we guarantee that we cant do in O(n / ( log ( log n ) ) )

is it because for comparison based sorting we cant do better than O(nlogn) time

Dark Mode

108 views

2 votes

It is given in the question we have input as $n$ single digit base $10$ integers .

It has two cases ,

**case 1:-**

if $n \leq10$ then we have n distinct digit which can be sort trivially in constant amount of time .

So for case 1 it will take O(1) amount time .

**Case 2:-**

If $n >10$ then , it means we have repeated digits which can take values from $[0,9]$ .

So this can be done easily by traversing the array once and counting how many times each integers occurs from the given n integers.

The program looks like:-

The complexity of the program is $\theta(n)$ .

So correct answer is (C) .

0

@jiren we are not using comparison based sorting here so that $\theta(n logn)$ logic won't apply here .

we can't do it in $\frac{n}{loglogn}$ because we have to traverse the whole array atleast once to examine all the elements which took atleast $O(n)$ time.

0

@Kabir5454 browhat i wanted to convey is that there are basically two types of sorting techniques that we learn in GATE syllabus

1. Linear time sorting ( Counting sort )

2. Comparison based sorting ( All sorting techniques we learn except radix sort )

since linear lime sorting is O(n) time and we used it so remaining option is comparison based sorting which takes O(nlogn) time minimum

now

what i wanted to ask is how can we guarantee that there is no Sorting algorithm whose time complexity is n/loglogn

0

I currently don't have any proof for it but by intuition to sort an array we need to examine all the elements once with examining all the elements once we can't sort them . To examine all the elements we need atleast O(n) time . So by this we can conclude we need atleast O(n) amount time not less than that.

0