MCPcopy Create free account
hub / github.com/apna-college/Alpha / countingSortDescending

Method countingSortDescending

2_Basic Sorting/CountingSort.java:26–44  ·  view source on GitHub ↗
(int arr[])

Source from the content-addressed store, hash-verified

24 }
25
26 public static void countingSortDescending(int arr[]) {
27 int largest = Integer.MIN_VALUE;
28 for(int i=0; i<arr.length; i++) {
29 largest = Math.max(largest, arr[i]);
30 }
31
32 int count[] = new int[largest+1];
33 for(int i=0; i<arr.length; i++) {
34 count[arr[i]]++;
35 }
36 int j = 0;
37 for(int i=count.length-1; i>=0; i--) {
38 while(count[i] > 0) {
39 arr[j] = i;
40 j++;
41 count[i]--;
42 }
43 }
44 }
45
46 public static void printArr(int arr[]) {
47 for(int i=0; i<arr.length; i++) {

Callers 1

mainMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected