Q12Comprehension5 Marks28 Apr 2024
Passage
Based on the above data, answer the given subquestions.
Consider the procedure evaluate as shown below, where P and Q are the lists of same length. If L1 = [4, 0, 2, 4] and L2 = [3, 1, 5, 3] then answer the given subquestions.
```
Procedure evaluate(P, Q)
if(P == []){
return(P)
}
else{
c = last(P) + last(Q)
return([c] ++ evaluate(init(P), init(Q)))
}
End evaluate
```
What will evaluate(L1, L2) return if line 6 and line 7 is replaced with below pseudocode?
c = first(P) + first(Q)
return([c] ++ evaluate(rest(P), rest(Q)))