👤

23. Se consideră algoritmul checkAcc(n, f, w, lw), unde n este un număr natural nenul (1 ≤ n ≤ 104 ), f este număr natural, w este un șir de lw (1 ≤ lw ≤ 104 ) numere naturale (w[1], w[2], ..., w[lw], unde 0 ≤ w[p] ≤ 104 , pentru p = 1, 2, ..., lw). Algoritmul checkAcc(n, f, w, lw) apelează algoritmul t(i, j, k), unde i, j și k sunt numere naturale. Algoritmul t(i, j, k) returnează rezultat boolean.
Algorithm checkAcc(n, f, w, lw):
acc ← True
If lw = 0 AND f ≠ 1 then
acc ← False
Else index ← 1
q ← 1
While (acc = True) AND (index ≤ lw) execute crt ← 1
changed ← False
While (changed = False) AND (crt ≤ n) execute
If t(q, w[index], crt) then
q ← crt
changed ← True
Else crt ← crt + 1
EndIf
EndWhile
If changed = False then
acc ← False
Else index ← index + 1
EndIf
EndWhile
If (index > lw) AND (acc = True) AND (q ≠ f) then
acc ← False
EndIf
EndIf
Return acc
EndAlgorithm
În care dintre situațiile de mai jos

algoritmul checkAcc(2, f, w, lw) va

returna True, știind că algoritmul t(i, j, k)

returnează True în cazurile din tabel, altfel

returnează False?

i j k

1 0 1

1 1 2

2 1 2

A. w = [0, 0, 1, 1], lw = 4 și f = 1

B. w = [1, 1, 1, 0], lw = 4 și f = 2

C. w = [0, 0, 1, 1], lw = 4 și f = 2

D. w = [0, 0, 0, 0], lw = 4 și f = 1​


Răspuns :