Question

In: Computer Science

Given the following array of 8 elements, show the steps to sortthe elements in ascending...

Given the following array of 8 elements, show the steps to sort the elements in ascending order using a radix sort. Fill in each of the following blanks.

81   546   677   9   97   12   53   22

Adjust with 0s:

Buckets for ones digit:

Buckets for tens digit:

Final Result:

Solutions

Expert Solution

The given array is : 81   546   677   9   97   12   53   22

Step Number 1:

Append 0 for double and single digit numbers so all the numbers consist of three digits.

Now we got : 081, 546, 677, 009, 097, 012, 053, 022.

Step Number 2:

Now the numbers are sorted based on one's digit in the ascending order.

We have : 081, 546, 677, 009, 097, 012, 053, 022.

Now we got : 081, 012, 022, 053, 546, 677, 097, 009.

Step Number 3:

Now the numbers are sorted based on ten's digit in the ascending order.

We have : 081, 012, 022, 053, 546, 677, 097, 009.

Now we got : 009, 012, 022, 546, 053, 677, 081, 097.

Step Number 4:

Now the numbers are sorted based on hundred's digit in the ascending order.

We have : 009, 012, 022, 546, 053, 677, 081, 097.

Now we got : 009, 012, 022, 053, 081, 097, 546, 677.

That is the sorted array.


Related Solutions

Written in MIPS assembly language If given an array which is sorted in ascending order, as...
Written in MIPS assembly language If given an array which is sorted in ascending order, as well as its length and a target value. You are asked to find the index of this target value in the array using binary search algorithm. Here is an example: array 1, 4, 6, 8, 10, 12 length 6 target 8 2 In this case, the returned result should be assigned to be 3, as array[3] is equal to target. (Note: The target will...
// Given an int array of size elements, determine if there are k elements that add...
// Given an int array of size elements, determine if there are k elements that add up to sum. // The array holds integers, both positive and negative and zero. // It is not possible to add zero elements (that's when k==0) to any sum, not even zero. // It is not possible to add any elements from an empty array. // Must be recursive and not iterative //bool K_element_sum(size_t k, int sum, int arr[], size_t size){}
Write a C program to show sum of 10 elements of array and show the average....
Write a C program to show sum of 10 elements of array and show the average. [10]
Given an array A that contains the following elements in this order 45, 2, 18, 7,...
Given an array A that contains the following elements in this order 45, 2, 18, 7, 23, 47, 3, 15, 32: (a) Build a min-heap using the bottom-up (reverse) method, showing your work. How many comparisons do you make? (b) Build a min-heap using the top-down (forward) method, showing your work. How many comparisons do you make? (c) Are the two heaps that you get identical? Is this a coincidence of this particular instance? Or would the same happen for...
Following is the algorithm of Quicksort for sorting an array of integers in ascending order. Partition(numbers,...
Following is the algorithm of Quicksort for sorting an array of integers in ascending order. Partition(numbers, lowIndex, highIndex) {    midpoint = lowIndex + (highIndex - lowIndex) / 2    pivot = numbers[midpoint]    done = false    while (!done) {       while (numbers[lowIndex] < pivot)          lowIndex++       while (pivot < numbers[highIndex])          highIndex--       if (lowIndex >= highIndex) {          done = true       }       else {          temp = numbers[lowIndex]          numbers[lowIndex] = numbers[highIndex]          numbers[highIndex] = temp                 lowIndex++          highIndex--       }    }    return highIndex } Quicksort(numbers, lowIndex, highIndex) {    if (lowIndex...
Radix sortCome up with an unsorted array of numbers (integer array). Sort the numbers in ascending...
Radix sortCome up with an unsorted array of numbers (integer array). Sort the numbers in ascending order and descending order and display them using radix sort. First sort in ascending, then reset the array to its original order and finally sort the array again in descending order. I need this in java language.
Radix sortCome up with an unsorted array of numbers (integer array). Sort the numbers in ascending...
Radix sortCome up with an unsorted array of numbers (integer array). Sort the numbers in ascending order and descending order and display them using radix sort. First sort in ascending, then reset the array to its original order and finally sort the array again in descending order. I need this in java language. Radix Sort assignment (CISP430 ignore this part) This is only for those who are using Java How many classes do I need? A: Node, Queue, Radix, Driver...
// This program uses a bubble sort to arrange an array of integers in // ascending...
// This program uses a bubble sort to arrange an array of integers in // ascending order (smallest to largest). It then display the array // before the sorting and after the sorting. Modify the program so it orders // integers in descending order (largest to smallest). Then add some code // to display the array at each step of the algorithm. You don't have to // modify anything in the main() function. All modification are inside // the bubbleSortArray()...
You are given an array of n elements, and you notice that some of them are...
You are given an array of n elements, and you notice that some of them are duplicates, that is, they appear more than once in the array. Show how to remove all duplicates from the array in time O( n log2 n ).
Given the following array [17, 15,21,208,16,122,212,53,119,43] Apply bubble sort algorithm and show the status of the...
Given the following array [17, 15,21,208,16,122,212,53,119,43] Apply bubble sort algorithm and show the status of the array after each pass. Also calculate how many comparisons you will be required to pass
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT