I have the following pseudo code:
Multiply(y,z)
1. if (z==0) return 0
2. else if (z is odd)
3. then return (Multiply(2y, floor(z/2)) + y )
4. else return (Multiply(2y, floor(z/2)))
Towards analysing this procedure's runtime, this recurrence relation is given as answer:
$\qquad \displaystyle T(z) = \begin{cases} 0 & z=0 \\ T(z/2)+1 & z>0\end{cases}$
Why is $T(z)=0$ when $z=0$? Shouldn't it be $1$ for this case?
And, the $+1$ in $T(z/2)\mathbf{+1}$ is because the worst case is
(multiply(2y, floor(z/2)) + y
(note the + y
). Am I correct?