logo

Crowdly

A = [3, 2, 5, 4, 6, 5, 0, 4, 1, 3] Massiiv A sorteeritakse Counting Sort a...

✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.

A = [3, 2, 5, 4, 6, 5, 0, 4, 1, 3]

Massiiv A sorteeritakse Counting Sort algoritmiga.

1 CountingSort(A, B, k)

2 for i = 0 to k

3 C[i] = 0;

4 for j = 1 to n

5 C[A[j]] += 1;

6 for i = 1 to k

7 C[i] = C[i] + C[i-1];

8 for j = n downto 1

9 B[C[A[j]]] = A[j];

10 C[A[j]] -= 1;

Milline on massiivi C sisu pärast algoritmi lõppemist?

NB! Massiiv C indekseeritakse 0st. Massiivid A ja B indekseeritakse 1st.

Andke vastusena arvude jada, kasutades arvude eraldajatena tühikuid (nt. 1 2 3 4 5 6)

More questions like this

Want instant access to all verified answers on moodle.taltech.ee?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!