Question:

Consider the function computes (X) whose pseudocode is given below :
\(\frac{\text{computeS (X)}}{S[1] ←1}\)
for i ← 2 to length(X)
S[i] ← 1
if X[i-1] ≤ X[i]
S[i] ← S[i] + S[i - 1]
end if
end for
return S
Which ONE of the following values is returned by the function computeS (X) for X= [6, 3, 5, 4, 10] ?

Updated On: Jul 9, 2024
  • [1, 1, 2, 3, 4]
  • [1, 1, 2, 3, 3]
  • [1, 1, 2, 1, 2]
  • [1, 1, 2, 1, 5]
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is C

Solution and Explanation

The correct option is (C) : [1, 1, 2, 1, 2].
Was this answer helpful?
0
0

Questions Asked in GATE AR exam

View More Questions