Question
Counting sort is a sorting technique that can be applied to a list holding integers from a certain range. Suppose that you are given a
Counting sort is a sorting technique that can be applied to a list holding integers from a certain range. Suppose that you are given a list of 10 integers and those integers are from the range 0-9. Instead of sorting those numbers directly, you count the frequency of each number and create a frequency list. Then you should use the frequency list to print the numbers in ascending order.
Input list: {1, 4, 1, 2, 7, 5, 2, 3, 9, 8}
Frequency list: {0, 2, 2, 1, 1, 1, 0, 1, 1, 1}
Then looking at the frequencies in frequency list, you should print the numbers in the original list in ascending order.
Two 1s: Print 1 1
Two 2s: Print 2 2
One 3: Print 3
One 4: Print 4
1 1 2 2 3 4
It should be a python code
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started