Please tell me where i'm making mistake
Hi
Could you please let me know about your approach with comments?
Otherwise one very simple approach is to use counting, Time complexity will be O(n)
i have used counting sort approach stil output is not correct,please point my mistake if you can
Hi
This loop is erroneous:
for(int i=n-1;i>=0;iā)
{
ARR[A[arr[i]]-1]=arr[i];
A[arr[i]]-- ;
}
If you print values of ARR after it you will get garbage values, so you cannot copy it to your final answer array i.e arr.
Fix this loop!
Also you cannot straightaway do:
ARR[A[arr[i]]-1]=arr[i]; Many indexes will overlap