Week 8: Wednesday ----------------- Q1. (40) Here is a description of an algorithm called the counting sort that, given an array of n numbers, sorts them in ascending order. The array must contain numbers between 0 and a positive integer m. 1. Create an auxiliary array count of size m + 1. The count will contain the number of occurrences of each number i between 0 and m in the original array. 2. Initialize elements of count to 0. 3. Traverse through the original array a. For each a[i], increment the element of count whose index is a[i]. 4. For each i from 0 to m, print i count[i] number of times. For example, suppose n = 10, m = 99 and a is: 10 9 48 21 2 5 9 48 12 10 Initially count[i] = 0 for all i from 0 to 99 While traversing throuh the array a, we update the values in the count array as shown below: count[10] = 1 count[9] = 1 count[48] = 1 count[21] = 1 count[2] = 1 count[5] = 1 count[9] = 2 count[48] = 2 count[12] = 1 count[10] = 2 Now for each i from 0 to 99, print i count[i] number of times: 2 5 9 9 10 10 12 21 48 48 Write a function that implements counting sort. The function should print the contents of the count array before each iteration. In the main function, declare an array of size 10; ask the user to enter 10 positive integers less than 100 into the array. Apply the sort function on this array. Q2. (60) Write a program that given a 5x5 matrix of positive integers, prints it in a spiral order. For example, if the input is 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 the output should be 11 12 13 14 15 20 25 30 35 34 33 32 31 26 21 16 17 18 19 24 29 28 27 22 23