Radix sort algorithm
Step 1:Starting Radix Sort. We will process digits from right to left. The first step will be to count occurances of digits from the input array.

Step 2: 36 has current digit 6. Add one to the 6 bin.

Step 3: 14 has current digit 4. Add one to the 4 bin.
Step 4: 27 has current digit 7. Add one to the 7
bin.

Step 5: 40 has current digit 0. Add one to the 0 bin.

Step 6 : 31 has current digit 1. Add one to the 1 bin.
Step 7: 17 has current digit 7. Add one to the 7 bin.

Step 8: 5 has current digit 5. Add one to the 5 bin.

Step 9: Now we will do a rolling summation of the count array, to
be used next as positions

But first we subtract 1 from the 0 position so that the
resulting sums yield correct positions in the Auxilliary
array.
Step 10: 0 + 1 is 1. Put that in position 1
Step 11: 1 + 0 is 1. Put that in position 2


Step 12: 1 + 0 is 1. Put that in position 3

Step 13: 1 + 1 is 2. Put that in position 4

Step 14: 2 + 1 is 3. Put that in position 5

Step 15: 3 + 1 is 4. Put that in position 6


Step 16 : 4 + 2 is 6. Put that in position 7

Step 17: 6 + 0 is 6. Put that in position 8


Step 18: 6 + 0 is 6. Put that in position 9


Step 19: Now use the Count array to decide where to move values
into the Auxilliary array
5 has current digit 5. So we look in position 5 of the Count array, to see that we put it in position 3 of the Auxilliary array.

And we decrement the value of Count array position 5

Step 20: 17 has current digit 7. So we look in position
7 of the Count array, to see that we put it in position 6 of the
Auxilliary array.

And we decrement the value of Count array position 7

Step 21: 31 has current digit 1. So we look in position 1 of the
Count array, to see that we put it in position 1 of the Auxilliary
array.

And we decrement the value of Count array position 1

Step 22: 40 has current digit 0. So we look in position 0 of the
Count array, to see that we put it in position 0 of the Auxilliary
array.

And we decrement the value of Count array position 0

Step 23: 27 has current digit 7. So we look in position 7 of the
Count array, to see that we put it in position 5 of the Auxilliary
array.

And we decrement the value of Count array position 7
Step 24: 14 has current digit 4. So we look in position 4 of the
Count array, to see that we put it in position 2 of the Auxilliary
array.

And we decrement the value of Count array position 4
Step 25: 36 has current digit 6. So we look in position 6 of the
Count array, to see that we put it in position 4 of the Auxilliary
array.

And we decrement the value of Count array position 6

Done with this pass1.
Step 26 : Now we move the value back to the Input Array
40 has current digit 4. Add one to the 4 bin.
Step 27: 31 has current digit 3. Add one to the 3 bin.

Step 28: 14 has current digit 1. Add one to the 1 bin

Step 29: 5 has current digit 0. Add one to the 0
bin.

36 has current digit 3. Add one to the 3 bin.
Step 30: 36 has current digit 3. Add one to the 3 bin.

Step 31: 27 has current digit 2. Add one to the 2 bin.

Step 32: 17 has current digit 1. Add one to the 1 bin.

Step 33: Now we will do a rolling summation of the count array, to
be used next as positions

But first we subtract 1 from the 0 position so that the
resulting sums yield correct positions in the Auxilliary
array.
Step 34: 0 + 2 is 2. Put that in position 1


Step 35: 2 + 1 is 3. Put that in position 2

3 + 2 is 5. Put that in position 3
Step 36:

3 + 2 is 5. Put that in position 3
Step 37:

5 + 1 is 6. Put that in position 4
Step 38:

5 + 1 is 6. Put that in position 4
Step 39:


6 + 0 is 6. Put that in position 5
Step 40:


6 + 0 is 6. Put that in position 6
Step 41:


6 + 0 is 6. Put that in position 7
Step 42:


6 + 0 is 6. Put that in position 8
Step 43:


6 + 0 is 6. Put that in position 9
Step 44:

Step 45: Now use the Count array to decide where to move values
into the Auxilliary array

And we decrement the value of Count array position 1

Step 46: 27 has current digit 2. So we look in position 2 of the
Count array, to see that we put it in position 3 of the Auxilliary
array.

And we decrement the value of Count array position 2

Step 47: 36 has current digit 3. So we look in position 3 of the
Count array, to see that we put it in position 5 of the Auxilliary
array.

And we decrement the value of Count array position 3

Step 48: 5 has current digit 0. So we look in position 0 of the
Count array, to see that we put it in position 0 of the Auxilliary
array.

And we decrement the value of Count array position 0

Step 49: 14 has current digit 1. So we look in position 1 of the
Count array, to see that we put it in position 1 of the Auxilliary
array.

And we decrement the value of Count array position 1

Step 50: 31 has current digit 3. So we look in position 3 of the
Count array, to see that we put it in position 4 of the Auxilliary
array.

And we decrement the value of Count array position 3

Step 51: 40 has current digit 4. So we look in position 4 of the Count array, to see that we put it in position 6 of the Auxilliary array

And we decrement the value of Count array position 4

Done with this pass2.
Step 52: Now we move the value back to the Input Array

The array after Sorting is 5,14,17,27,31,36,40
Show how the Radix sort algorithm sorts the array: 36 14 27 40 31 17 5....
7. (14 points) Use LSD-first Radix Sort algorithm to sort the following array of numbers. Write the worst case, the best case time complexity and discuss if these sorting algorithms are stable and in-place? In what cases using these algorithms would not be efficient? (You must run Counting Sort for each digit explicitly.) A=[22,15,16,13,23,45,0,23,123]
8. (5 points) Trace merge sort algorithm as it sorts the following sequence of integer array into a descending order. 42 45 10 64 55 37 96 7 9. (5 points) Trace shell sort algorithm that halves the gap size at each iteration as it sorts the following sequence of integer array into an ascending order. 42 18 10 64 85 37 96 71
8. (5 points) Trace merge sort algorithm as it sorts the following sequence of integer array...
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 =...
6. (10 points) Trace insertion sort algorithm as it sorts the following sequence of integer array into an ascending order. 17 3 12
؟
5- How could you design a Three-Pass-Radix sort algorithm to sort the following group of integ containing three digits: 666,6,66,323, 13, 333, 111, 23, 100, 102
For the array 23, 17, 14, 6, 13, 10, 5, 18, use Quick Sort to sort it. Show each step.
PROBLEM #11 What are the two algorithms used to sort an array? How do they work? -------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------------------------- PROBLEM #12 Given the following array 'jumbled', what will the array be after the first swap of a selection sort algorithm? (Assume the algorithm sorts in ascending order). --------------------------------------------------------------------------------------------------------------- */ int jumbled[] = {12, 5, 3, 1, 9, 100, 45}; /* --------------------------------------------------------------------------------------------------------------- PROBLEM #13 Given the following array 'jumbled2', what will the array be after the third swap of a...
1.Show the state of the following array after the outer loop of the bubble sort algorithm has executed one time. [0] [1] [2] [3] [4] [5] 19 23 2 4 99 1 2. Show the state of the following array after the outer loop of the selection sort algorithm has executed two times. [0] [1] [2] [3] [4] [5] 12 1 9 23 17 11 3. Show the state of the following array after the outer loop of the insertion...
For C++ Write a program that randomly generates 100 integers and sorts them using radix sort. Note: Your output would not be the same as this sample output due to the randomness. Sample output: 0 0 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 3 3 3 3 4 4 4 4 4 4 4 4 5 5 5 6 6 6 6 6 6 7 7 7 7 7 7...
Q3) Apply Quick sort algorithm to sort the following Array (Show complete steps, and show the values of p,r and q) 7 13 5 2 4 10 15 6 3 6