GATE | DA | 2024 | DBMS | Question 39

Last Updated :
Discuss
Comments

Consider the function computeS(X) whose pseudocode is given below:

computeS(X)
𝑆[1] ← 1
for 𝑖 ←2 to length(X)
𝑆[𝑖] ← 1
if 𝑋[𝑖 βˆ’ 1] ≀ 𝑋[𝑖]
𝑆[𝑖] ← 𝑆[𝑖] + 𝑆[𝑖 βˆ’ 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]?


[1,1,2,3,4]

[1,1,2,3,3]

[1,1,2,1,2]

[1,1,2,1,5]

Share your thoughts in the comments