Back

Question: 2018 Winter Final - 10

Author: Michiel Smid
Consider the recursive algorithm $\SundayEveningExam$, which takes as input an integer $n \geq 1$: (see file for removed code) Let $P(n)$ be the number of times the line "I don't like Sunday evening exams" is printed when running algorithm $\SundayEveningExam(n)$. Which of the following is true for all $n \geq 1$?
(a)
$P(n) = 1 + \frac{n(n-1)}{2}$
(b)
$P(n) = \frac{n(n+1)}{2}$
(c)
$P(n) = 1 + \frac{n(n+1)}{2}$
(d)
$P(n) = \frac{n(n-1)}{2}$