Complete the code to initialize the count array with zeros.
int[] count = new int[max + 1]; for (int i = 0; i < count.Length; i++) { count[i] = [1]; }
The count array must start with all zeros to count occurrences correctly.
Complete the code to count the occurrences of each element in the input array.
foreach (int num in arr) { count[[1]]++; }
We use the current number 'num' as the index to increment its count.
Fix the error in updating the count array to hold cumulative counts.
for (int i = 1; i < count.Length; i++) { count[i] = count[i] [1] count[i - 1]; }
Cumulative counts are found by adding the previous count to the current count.
Fill both blanks to place elements in the output array in sorted order.
for (int i = arr.Length - 1; i >= 0; i--) { output[count[arr[i]] [1]] = arr[i]; count[arr[i]] [2]; }
We subtract 1 to get the correct index and then decrement the count after placing the element.
Fill all three blanks to copy the sorted output back to the original array.
for (int i = 0; i < arr.Length; ) { arr[[1]] = output[[2]]; [3]; }
We copy each element from output to arr using the same index 'i' and increment 'i' in the loop.
