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

// 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]
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...
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
Write a C++ program to find K largest elements in a given array of integers. For...
Write a C++ program to find K largest elements in a given array of integers. For eeample, if K is 3, then your program should ouput the largest 3 numbers in teh array. Your program is not supposed to use any additional array.
SHOW ALL STEPS, FORMULAS, AND EXPLANATIONS Given the following list of items: a. Classify the items...
SHOW ALL STEPS, FORMULAS, AND EXPLANATIONS Given the following list of items: a. Classify the items as A, B, or C b. Determine the economic order quantity for each item (round to the nearest whole unit) Item Estimated Annual Demand Ordering Cost Holding Cost (%) Unit Price H4-010 20,000 55 25 4.5 H5-201 60,200 65 25 6 P6-400 9,800 85 35 30.5 P6-401 14,500 55 35 14 P7-100 6,250 55 35 11 P9-103 7,500 55 45 24 TS-300 21,000 45...
What is the running time of Quicksort when the input array is sorted in ascending order?...
What is the running time of Quicksort when the input array is sorted in ascending order? (please explain in detail)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT