Describe counting sort. When is counting applicable?
Show the steps of radix sort for the following sequence. Use counting sort to sort single digits. 22 34 7 88 3 66 71 94 15
Note: when a problem has an array of real numbers, you
cannot use counting sort or radix sort.
For this problem, you are given a number t and an array A with n real numbers that are not sorted. Describe an algorithm that finds the t numbers in A that are closest to the median of A. That is, if A = {x1, . . . , xa) and xrn is the median, we want to find the t...
Write a program in Java that performs the Counting Sort algorithm. a) Create the countingSort method. Use the pseudocode shown in the lecture. b) Test your codes by writing a program that uses the following input array: int[] array_A = {6, 0, 2, 0, 1, 3, 4, 6, 1, 3, 2}; c) Your output should display the following versions of the arrays: I. The original input array A II. The counting array C after the counting (lines 4-5 in pseudocode)...
2. Sort the following numbers using counting sort 8 11 4 7 6 912 Index Sum Count Position Sorted Input
Question 3 (2 points) Linear time sort a) Call COUNTING-SORT on the input array A (6,0,2,0,1,3,4,6,1,3,2). Using the plots on slide #67 as a model, illustrate array C after the second for loop (line 5 to 6) and the third for loop (line 7 to 8) are executed, respectively; then illustrate array B and C after executing the first 2 iterations of the fourth for loop (line 10 to 12), respectively Using the plots on slide #81 as a model,...
Sort the numbers: 2, 1, 4, 5, 7, 1, 7, 11, 8, 9 using the counting sort.
16. (5 points) Trace counting sort algorithm as it sorts the array into a descending order. ASSUMPTION: (1) Each data element (i.e., aſil) is associated with a complicated object. As discussed, counting sort with a simple frequency count does not work. (2) Show how to guaranted the stability of repeating values. As we did in the class, please use a subscript to specify the order of the same keved values. (3) Show the steps as detail as possible. A =...
Write a Java program to implement Counting Sort and write a driver to test it. Note: use random number generator to generate your input with n = 10, 50, and 100. Verify that the running time is O(n).
Exercise 4.3. Counting exchanges and comparisons with Selection Sort Original data set: 60,30,15,51,97,44,37,33 Show how many exchanges and comparisons using the above data set for a selection sort and their totals. Pass Exchanges Comparisons 1 2 3 4 5 6 7 Totals
write a code in python for COUNTING SORT. check the runtime for the algorithms for varying input sizes. Input size n (size of the list) the following list sizes 1. 10,000 2. 100,000 3. 1000,000 For each of these sizes we are going to have two types of input: a. Sorted list (ascending order) of elements from range (1:n) b. Sorted list (descending order) of elements from range (n:1)