0

I have tried several times to find the answer of this question and every time my result is 30 but the answer key shows the result to 32 and I don't understand why it should be 32??!! it is a data structure question related to recursive functions;

Let function F be defined recursively as follows: F(0) = 3; F(n + 1) = 2F(n) + n^2 Then F(3) is given by?

1
  • Please edit the question to show your work for evaluating F(3). Also, welcome to SO and please read tour and How to Ask. Commented Mar 18, 2018 at 20:49

1 Answer 1

2

This is not a data structures question. If we implement the function in, say, Python:

def f(n):
    if n == 0:
        return 3
    else:
        return 2 * f(n-1) + (n-1)**2

We get this:

f(3)
=> 30

So it seems to me that the answer key is mistaken.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.