Advise on Sorting method

Which sorting algortihm should be used for sorting an array of length 10^5
and elements less than 10^9

Do this:- sort(a,a+n); in C++. Done. :slight_smile:

4 Likes

Which language is better for cp ? C++ or python ?

1 Like

According to me, C++ :slight_smile:

5 Likes

Depends on question. But yeah c++ for most of the cases as karan said.
Sometimes ques can be hacked using inbuilt functions of python or due to 5x time limit :stuck_out_tongue:

5 Likes

Yeah in C++ but sort(a,a+n) is not working . I even have the time limit 2 sec but still its giving TLE.
Dont know why?

did you call in the required header files?

1 Like

Your code probably has some errors, share your code so we can point that out for u or search it urself

1 Like

C++ is father of all languages…:stuck_out_tongue:

You may post your link(of code) here. I’ll answer your query in 2-3 days :slight_smile:

1 Like

That’s not possible when n=10^5.

3 Likes

Merge Sort I would say, or Heap Sort, depends on one’s preference, the inbuilt sort function in c++ is I think quick sort, which I somewhere read is normally 10-20% faster than any normal sorting algorithm you write in Nlogn.

2 Likes

what do u mean by ‘not working’
is it giving some error while using that func ?
or tle ?
if tle then it means that there might be some better way to solve this ques
perhaps without sort

Thanks guys i was just confused .The sort function was working correctly i got confused .
there was some other error due to which it was giving TLE . Thank you all for you support . :smiley: