100 Raspunsuri multiple
Se consideră algoritmii g(v, n) și f(v, n, t), unde n este un număr natural (), v este un vector cu n elemente numere naturale, iar t este un număr natural.
Algoritm 1
Algorithm f(v, n, t)
g(v, n)
c ← INF; aux ← []
For i ← 1, 3 execute aux[i] ← 0 EndFor
For i ← 1, n − 2 execute
l ← i + 1; r ← n − 1
While l < r execute
s ← v[i] + v[l] + v[r]
If |s − t| < |c − t| then c ← s; aux ← [v[i], v[l], v[r]] EndIf
If s < t then l ← l + 1
Else If s > t then r ← r − 1
Else Return aux EndIf
EndWhile
EndFor
Return aux
EndAlgorithmAlgoritm 2
Algorithm g(v, n)
For i ← 1, n − 1 execute
For j ← 1, n − i execute
If v[j] > v[j + 1] then
temp ← v[j]; v[j] ← v[j + 1]; v[j + 1] ← temp
EndIf
EndFor
EndFor
EndAlgorithmPrecizați care dintre afirmațiile de mai jos sunt adevărate:
34 / 60