Cho biết độ phức tạp của đoạn mã giả sau dùng ký hiệu big-O.int F(int n)if (n <= 2)return 1elsereturn F(n − 2) * F(n − 2)a.O(2^(n/2))b.O(2^n)c.O(n^2)d.O( n )

Question

Cho biết độ phức tạp của đoạn mã giả sau dùng ký hiệu big-O.int F(int n)if (n <= 2)return 1elsereturn F(n − 2) * F(n − 2)a.O(2^(n/2))b.O(2^n)c.O(n^2)d.O( n )
🧐 Not the exact question you are looking for?Go ask a question

Solution 1

Đoạn mã giả trên có độ phức tạp là O(2^n).

Giải thích: Hàm F(n) gọi đệ quy tới hàm F(n-2) hai lần. Do đó, số lượng phép tính cần thực hiện tăng lên theo cấp số nhân, tức là 2^n.

Vì vậy, đáp án chính xác là b. O(2^n). Knowee AI StudyGPT is a powerful AI-powered study tool designed to help you to solve study problem. Knowee AI StudyGPT is a powerful AI-powered study tool designed to help

to solve study problem. Knowee AI StudyGPT is a powerful AI-powered study tool designed to help you to solve study problem. Knowee AI StudyGPT is a powerful AI-powered study tool designed to help you to solve study problem. Knowee AI StudyGPT is a powerful AI-powered study tool designed to help you to solve study problem. Knowee AI StudyGPT is a powerful AI-powered study tool desi

This problem has been solved

Similar Questions

Cho biết độ phức tạp của đoạn mã giả sau dùng ký hiệu big-O.int F(int n)if (n <= 2)return 1elsereturn F(n − 2) * F(n − 2)a.O(2^(n/2))b.O(2^n)c.O(n^2)d.O( n )

Cho biết độ phức tạp của đoạn mã giả sau dùng ký hiệu big-O.s = 0for (i = 1; i <= n; i *= 3)s = s + a[i]a.O( n )b.O(n^2)c.O(logn)d.O(nlogn)Clear my choice

What is the time complexity of searching for an element in a circular linked list?Select one:a.O(n)b.O(nlogn)c.O(1)d.O(n2)

What is the Big O notation of a binary search algorithm applied to a sorted array?Question 12Answera.Ob.O(log n)c.O(n log n)d.O(n^2)

What is the space complexity for deleting a linked list?Select one:a.O(1).b.O(n).c.Either o(1) or o(n).d.O(logn).

1/3