#4228. [GESP202403 八级 C++] 第 10 题

[GESP202403 八级 C++] 第 10 题

下面程序的时间复杂度为( )。

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

{{ select(1) }}

  • O(2n)O(2^n)
  • O(ϕn)O(\phi^n),其中 ϕ=5+12\phi = \dfrac{\sqrt{5}+1}{2}
  • O(n)O(n)
  • O(1)O(1)