From 27f1c1a2eddeec8bb8f4349b57695cf66848cf0f Mon Sep 17 00:00:00 2001 From: Tyagirohan <93430695+Tyagirohan@users.noreply.github.com> Date: Fri, 21 Oct 2022 09:40:44 -0500 Subject: [PATCH] Create counting sort.c --- algorithms/C/sorting/counting sort.c | 36 ++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 algorithms/C/sorting/counting sort.c diff --git a/algorithms/C/sorting/counting sort.c b/algorithms/C/sorting/counting sort.c new file mode 100644 index 00000000..2bc0df7b --- /dev/null +++ b/algorithms/C/sorting/counting sort.c @@ -0,0 +1,36 @@ +// Counting sort is a stable Sorting Algorithm +#include + +void countSort(int a[],int n,int key) +{ + int count[50]={0}; // assigning all elements as zero + int i,j; + + for(i=0;ikey) + key=a[i]; + } + // calling counting sort + countSort(a,n, key); + return 0; +}