diff --git a/Count Sort b/Count Sort new file mode 100644 index 0000000..4233ee7 --- /dev/null +++ b/Count Sort @@ -0,0 +1,42 @@ +//find tthe coiunt of every distinct element +//calculate the position of each element in sorted array +#include +#include +using namespace std; +void countSort(int arr[],int n){ + int k=arr[0]; + for(int i=0;i=0;i--){ + output[--count[arr[i]]]=arr[i]; //assigning vaues after sorting //firstly decrement the value of count arr and then assigning the correct index + } + for(int i=0;i>n; +int arr[n]; +cout<<"Enter values of array "; +for(int i=0;i>arr[i]; +} + +countSort(arr,n); +for(int i=0;i