Counting Sort 1
this sorting is done by hash function.
it is a better approach which take less time , approx O(N).
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
int n;
cin>>n;
int arr[100]={0},inp[n];
for(int i=0;i<n;i++)
{
cin>>inp[i];
arr[inp[i]]++;
}
for(int i=0;i<100;i++)
cout<<arr[i]<<" ";
return 0;
}
0 Comments:
Post a Comment