C
C
Chemodan2282020-04-21 16:40:22
Algorithms
Chemodan228, 2020-04-21 16:40:22

A question about estimating the complexity of an algorithm?

5e9ef75d42b05285780763.jpeg
Guys why in the line where the i-th Fibonacci number is the time complexity is O (n)?
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
Wataru, 2020-04-26
@wataru

Apparently, here it is considered how many times this line will be executed in total, and not how much it itself takes.
Because this line is in a loop that repeats O(n) times, then this line (which runs in constant time) will take O(n) in total.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question