retagged by
294 views
0 votes
0 votes
Q- consider an array A of size K  where each element is either 10 or 20 what is the minimum time required to sort an array A??????
retagged by

1 Answer

0 votes
0 votes
take B{k] and constant=10

for i=0 to size

       if(A[i]==c)

          B[i]=A[i]; ---- fill 10 from left side

       else

          B[k-i]=A[i]; ---- fill 20 from right side

 

taking O(N) only

Related questions

1 votes
1 votes
0 answers
1
0 votes
0 votes
1 answer
2
0 votes
0 votes
3 answers
3
0 votes
0 votes
1 answer
4
Deepalitrapti asked Sep 11, 2018
347 views