A recursive function \(ℎ\), is defined as follows: \(\begin{array} {} h(m) &…

2017

A recursive function \(ℎ\), is defined as follows:

\(\begin{array} {} h(m) & =k, \text{if } m=0 \\ &=1, \text{if } m=1 \\ &= 2 h(m-1)+4h(m-2), \text{if } m \geq 2 \end{array}\)

If the value of \(ℎ(4)\) is \(88\) then the value of \(𝑘\) is:

  1. A.

    0

  2. B.

    1

  3. C.

    2

  4. D.

    - 1

Attempted by 53 students.

Show answer & explanation

Correct answer: C

Key idea: use the recurrence to express h(2), h(3), and h(4) in terms of k, then solve for k using h(4)=88.

  1. Given: h(0) = k and h(1) = 1.

  2. Compute h(2): h(2) = 2·h(1) + 4·h(0) = 2·1 + 4·k = 2 + 4k.

  3. Compute h(3): h(3) = 2·h(2) + 4·h(1) = 2(2 + 4k) + 4·1 = 8 + 8k.

  4. Compute h(4): h(4) = 2·h(3) + 4·h(2) = 2(8 + 8k) + 4(2 + 4k) = 24 + 32k.

  5. Set h(4) = 88 and solve: 24 + 32k = 88 ⇒ 32k = 64 ⇒ k = 2.

Answer: k = 2

Explore the full course: Coding For Placement