ProgrammingModerateTCS NQT · Infosys

What will be the output of the following pseudocode?

What will be the output of the following pseudocode?
Integer t[0..10]
t[0] = 0
t[1] = 1
t[2] = 1
for (each i from 3 to 10)
    t[i] = t[i - 1] + t[i - 2] + t[i - 3]
end for
Print t[7], t[10]
  1. A. 44 274
  2. B. 13 149
  3. C. 24 81
  4. D. 24 149

Correct answer: D. 24 149

The tribonacci numbers run 0, 1, 1, 2, 4, 7, 13, 24, 44, 81, 149: t[7] = 24 and t[10] = 149.

More Pseudocode and Code Tracing questions

Exams that ask this topic