1.

If comparison based sorting algorithm is used construct the suffix array, then what will be time required to construct the suffix array?(a) O(nlogn)(b) O(n^2)(c) O(n^2logn)(d) O(n^2) + O(logn)The doubt is from Arrays Types topic in portion Arrays Types of Data Structures & Algorithms II have been asked this question during an internship interview.

Answer»

Correct choice is (c) O(n^2logn)

Easy explanation - On average COMPARISON BASED sorting algorithms require O(NLOGN) comparisons. But comparing a suffix TAKES O(n). So, overall TIME to construct the suffix array will be O(nlogn) * O(n) = O(n^2logn).



Discussion

No Comment Found

Related InterviewSolutions