$\newcommand{\Hello}{{\rm H {\scriptsize ELLO}}}
\newcommand{\elsesp}{\phantom{\mathbf{else}\ }}$
Consider the recursive algorithm $\Hello$, which takes as input an integer $n \geq 0$:
If we run algorithm $\Hello(7)$, how many times is the word "hello" printed?
(a)
4
(b)
6
(c)
5
(d)
7
Solution
Let’s draw a recursive tree to find out how many times the word \enquote{hello} is printed when we run $HELLO(7)$.
As can be seen, the word \enquote{hello} is printed 5 times when we run $HELLO(7)$.