Question: What is the time complexity of the below algorithm: def myFunction ( n ) : if n < 2 : out = 1

What is the time complexity of the below algorithm:

def myFunction(n):

if n < 2:

out = 1

else:

out = myFunction(n-1) + myFunction(n-2)

return out

Group of answer choices

O(2^n)

O(log(n))

O(n log(n))

O(n^2)

 

Step by Step Solution

3.40 Rating (153 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The detailed answer for the above question is provided below The given function is a re... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!