Answered step by step
Verified Expert Solution
Question
1 Approved Answer
**Please do not copy/paste a solution to this question already asked** I have a general idea of the answer, just need help polishing the edges
**Please do not copy/paste a solution to this question already asked** I have a general idea of the answer, just need help polishing the edges
part a), I know we would have to manipulate the input by using/assigning a key to each element and such that Counting can be used to sort the keys....Just need to make sure that the manipulation does not have a cost higher than then a straight sorting algorithm with nlogn complexity. Please use this theory to answer.
part b) radix sort with counting sort built in would work.
Exercise 1 (30 points) Counting Sort COUNTING-SORT (A. B.k) 1 let C[0..k] be a new array 2 fori - 0 to k 4 for j = l to A. length 6 [i] now contains the number of elements equal to i 7 for i= l to k 9 [i] now contains the number of elements less than or equal to i 10 for j - A.length downto 1 Suppose that we are given a sequence A of n positive real numbers (ai, an, an) to sort a) 2 points) Can you use Count Sort AS IS to sort A? Explain b) (28 points) How can you adapt Counting Sort to sort the sequence A? Clearly state your assumptions and describe clearly using pseudocode your new Counting Sort algorithm Exercise 1 (30 points) Counting Sort COUNTING-SORT (A. B.k) 1 let C[0..k] be a new array 2 fori - 0 to k 4 for j = l to A. length 6 [i] now contains the number of elements equal to i 7 for i= l to k 9 [i] now contains the number of elements less than or equal to i 10 for j - A.length downto 1 Suppose that we are given a sequence A of n positive real numbers (ai, an, an) to sort a) 2 points) Can you use Count Sort AS IS to sort A? Explain b) (28 points) How can you adapt Counting Sort to sort the sequence A? Clearly state your assumptions and describe clearly using pseudocode your new Counting Sort algorithmStep 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