The Gateway to Computer Science Excellence
0 votes
123 views
if an array has 1000 elements which sorting to be used ?
in Programming by Active (3.7k points) | 123 views

1 Answer

+2 votes
Best answer
If the range(0 - n) is given for the input numbers, then Counting sort can be useful in terms of Time complexity => O(n + k). and space complexity => O(k) if maximum key value is significantly smaller than the no. of inputs.

Otherwise, Heap sort would be the best one to use as Time Complexity => O(n*log(n)) and space complexity => O(1).
by Junior (819 points)
selected by
0
Dear sir please tell also about the sorting algorithm which takes maximum time and has maximum time and space compleixtiy
+1
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,666 questions
56,168 answers
193,841 comments
94,047 users