Back

Solution: 2014 Fall Final - 10

Author: Michiel Smid

Question

Consider the following recursive function:
$f(0) = $ $-17,$
$f(n) = $ $f(n - 1) + 8n - 2\; \ \text{for all}$ $\text{integers}\ n \geq 1.$
Which of the following is true?
(a)
for all $n \geq 0$: $f(n) = 4n^{2} - 2n - 17$
(b)
for all $n \geq 0$: $f(n) = 3n^{2} + n - 17$
(c)
for all $n \geq 0$: $f(n) = 3n^{2} - n - 17$
(d)
for all $n \geq 0$: $f(n) = 4n^{2} + 2n - 17$

Solution

Let’s calculate $f(1)$ first

$f(1) = f(0) + 8 \cdot 1 - 2 $

$f(1) = -17 + 8 - 2 $

$f(1) = -11 $

  • $ f(n) = 3n^{2} - n - 17 $
    $ f(1) = 3 \cdot 1^2 - 1 - 17 $
    $ f(1) = 3 - 1 - 17 $
    $ f(1) = -15 $
  • $ f(n) = 3n^{2} + n - 17 $
    $ f(1) = 3 \cdot 1^2 + 1 - 17 $
    $ f(1) = 3 + 1 - 17 $
    $ f(1) = -13 $
  • $ f(n) = 4n^{2} - 2n - 17 $
    $ f(1) = 4 \cdot 1^2 - 2 - 17 $
    $ f(1) = 4 - 2 - 17 $
    $ f(1) = -15 $
  • $ f(n) = 4n^{2} + 2n - 17 $
    $ f(1) = 4 \cdot 1^2 + 2 - 17 $
    $ f(1) = 4 + 2 - 17 $
    $ f(1) = -11 $

The correct answer is $ f(n) = 4n^{2} + 2n - 17 $ because it is the only one that gives the correct value for $ f(1) $