1.

What is the time complexity of Kadane’s algorithm?(a) O(1)(b) O(n)(c) O(n^2)(d) O(5)The question was asked by my school teacher while I was bunking the class.My question is taken from Kadane’s Algorithm in division Dynamic Programming of Data Structures & Algorithms II

Answer»

Right option is (b) O(n)

EASY explanation - The TIME complexity of Kadane’s algorithm is O(n) because there is only ONE for loop which scans the entire ARRAY EXACTLY once.



Discussion

No Comment Found

Related InterviewSolutions