A
UBB · Informatică
203 Raspunsuri multiple

Se consideră algoritmul ceFace(v, st, dr), unde v este un vector de n numere întregi (−10^9 ≤ v[1], v[2], ..., v[n] ≤ 10^9), iar st și dr sunt limitele indicilor (1 ≤ st ≤ dr ≤ n). Un pair este o structură de date care reține două valori, notate convențional first și second, unde first ≤ second.

Algoritm 1

Algorithm ceFace(v, st, dr)
  If st = dr then
    Return {v[st], v[st]}
  EndIf
  If dr − st = 1 then
    Return {min(v[st], v[dr]), max(v[st], v[dr])}
  EndIf
  mij ← (st + dr) DIV 2
  p1 ← ceFace(v, st, mij)
  p2 ← ceFace(v, mij+1, dr)
  Return {min(p1.first, p2.first), max(p1.second, p2.second)}
EndAlgorithm

Care dintre următoarele afirmații sunt adevărate?

16 / 30