1.

Consider the brute force implementation in which we find all the possible ways of multiplying the given set of n matrices. What is the time complexity of this implementation?(a) O(n!)(b) O(n^3)(c) O(n^2)(d) ExponentialThis question was posed to me in unit test.This interesting question is from Matrix-chain Multiplication topic in portion Dynamic Programming of Data Structures & Algorithms II

Answer»

The CORRECT option is (d) Exponential

Easy explanation - The time COMPLEXITY of finding all the possible WAYS of multiplying a set of n MATRICES is given by (n-1)^th Catalan NUMBER which is exponential.



Discussion

No Comment Found

Related InterviewSolutions