Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 88677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T22:35:50+00:00 2026-05-10T22:35:50+00:00

I understand Big-O notation, but I don’t know how to calculate it for many

  • 0

I understand Big-O notation, but I don’t know how to calculate it for many functions. In particular, I’ve been trying to figure out the computational complexity of the naive version of the Fibonacci sequence:

int Fibonacci(int n) {     if (n <= 1)         return n;     else         return Fibonacci(n - 1) + Fibonacci(n - 2); } 

What is the computational complexity of the Fibonacci sequence and how is it calculated?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T22:35:51+00:00Added an answer on May 10, 2026 at 10:35 pm

    You model the time function to calculate Fib(n) as sum of time to calculate Fib(n-1) plus the time to calculate Fib(n-2) plus the time to add them together (O(1)). This is assuming that repeated evaluations of the same Fib(n) take the same time – i.e. no memoization is used.

    T(n<=1) = O(1)

    T(n) = T(n-1) + T(n-2) + O(1)

    You solve this recurrence relation (using generating functions, for instance) and you’ll end up with the answer.

    Alternatively, you can draw the recursion tree, which will have depth n and intuitively figure out that this function is asymptotically O(2n). You can then prove your conjecture by induction.

    Base: n = 1 is obvious

    Assume T(n-1) = O(2n-1), therefore

    T(n) = T(n-1) + T(n-2) + O(1) which is equal to

    T(n) = O(2n-1) + O(2n-2) + O(1) = O(2n)

    However, as noted in a comment, this is not the tight bound. An interesting fact about this function is that the T(n) is asymptotically the same as the value of Fib(n) since both are defined as

    f(n) = f(n-1) + f(n-2).

    The leaves of the recursion tree will always return 1. The value of Fib(n) is sum of all values returned by the leaves in the recursion tree which is equal to the count of leaves. Since each leaf will take O(1) to compute, T(n) is equal to Fib(n) x O(1). Consequently, the tight bound for this function is the Fibonacci sequence itself (~θ(1.6n)). You can find out this tight bound by using generating functions as I’d mentioned above.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to understand the performance of database indexes in terms of Big-O notation.
I've been working through a recent Computer Science homework involving recursion and big-O notation.
I found some references about big O notation, but as far as I can
I am learning about Big O Notation running times and amortized times. I understand
Possible Duplicate: Plain English explanation of Big O I know Big O notation is
I'm currently studying and trying to implement some algorithms. I'm trying to understand Big
I understand what System.WeakReference does, but what I can't seem to grasp is a
I understand the difference between String and StringBuilder ( StringBuilder being mutable) but is
what is the best way to understand a big company project in java?
This is my little big question about containers, in particular, arrays. I am writing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.