1.

Which of the following implementations of Catalan numbers has the smallest time complexity?(a) Dynamic programming(b) Binomial coefficients(c) Recursion(d) All have equal time complexityThis question was posed to me in unit test.My question is from Catalan Number using Dynamic Programming in section Dynamic Programming of Data Structures & Algorithms II

Answer»

Correct option is (B) Binomial coefficients

For explanation: The time complexities are as follows:

DYNAMIC PROGRAMMING: O(n^2)

RECURSION: Exponential

Binomial coefficients: O(n).



Discussion

No Comment Found

Related InterviewSolutions