edited by
642 views
2 votes
2 votes

shouldn't the answer be O(n^3)?

edited by

1 Answer

Best answer
1 votes
1 votes
May be the answer given is wrong !!

It should be O(n^2) as the best you can do is go for the ELSE part.. where u can clearly see that we will run a O(n) loop n times.. making the total complexity O(n^2)
selected by

Related questions

1 votes
1 votes
1 answer
1
Markzuck asked Jan 6, 2019
507 views
Please show the ideal way to deal with such comparisons as I am getting g>=f IN genral what logic shall be followed to analyse such complex comparions?
0 votes
0 votes
1 answer
2
Markzuck asked Dec 29, 2018
803 views
cant we write the recurrance relation for bar() as T(n) = 5T(n-1) + c,like cant we take both the recurrance call as combined as both have same parameter?and if not, then ...
1 votes
1 votes
0 answers
3
1 votes
1 votes
1 answer
4