Answered step by step
Verified Expert Solution
Question
1 Approved Answer
ASAP please answer these 3 questions For the next three questions, suppose you sort array A using the counting sort algorithm, the pseudocode for which
ASAP please answer these 3 questions
For the next three questions, suppose you sort array A using the counting sort algorithm, the pseudocode for which is printed below. (Assume k=5 for this example.) Here is Array A. The top row is the index, the second row is the actual data. 1 2 3 4 5 6 7 8 2 5 3 0 2 3 0 3 Here is Array C. The top row is the index, the second row is currently empty. 0 1 2 3 4 5 5 COUNTING-SORT(A, B, k) | let C[0..k] be a new array 2 for i 0 to k 3 C[i] = 0 4 for j = I to A. length 5 CIA[l] = CLAUD] + 1 6 // Cli] now contains the number of elements equal to i. 7 for i I to k 8 C[i] = C[i] + C[i-1] 9 // Clil now contains the number of elements less than or equal to i. 10 for j A.length downto 1 11 B(CIAL II] = A[] 12 CIAL]] = CAD/l) - 1 Question 36 1 pts What does the Carray look like after the first for loop (lines 2 and 3) is completed? (In the answers below, the top row is the index, the second row is the actual data.) O 0 1 2 3 4 5 1 2 4 6 7 8 O 0 1 2 3 4 5 20 23 0 1 O 0 1 2 3 4 5 0 0 0 0 0 0 OO 1 2 3 4 5 12 2 4 7 7 8 0 1 2 3 4 5 2 2 4.678 Question 37 1 pts What does the C array look like after the second for loop (lines 4 and 5) is completed? (In the answers below, the top row is the index, the second row is the actual data.) 0 1 2 3 4 5 1 2 4 6 7 8 O 0 12.345 202 30 1 O 0 1 2 3 4 5 000 000 O 0 1 2 3 4 5 2.2 4 6 7 8 0 1 2 3 4 5 2247178 Question 38 1 pts What does the Carray look like after the third for loop (lines 7 and 8) is completed? (In the answers below, the top row is the index, the second row is the actual data.) O 0 1 2 3 4 5 2 241 71 718 O 0 1 2 3 4 5 2 2 4 6 7 8 O 0 1 2 3 4 5 olololololo 0 1 2 3 4 5 12 46 7 8 0 1 2 3 4 5 210 2 3 0 1 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