The Gateway to Computer Science Excellence
0 votes
if an array has 1000 elements which sorting to be used ?
in Programming by Active (3.8k points) | 125 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 (829 points)
selected by
Dear sir please tell also about the sorting algorithm which takes maximum time and has maximum time and space compleixtiy
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,737 questions
57,385 answers
105,359 users