1.

What is a time complexity for finding the longest substring that is repeated in a string?(a) O (log n!)(b) Ɵ (n!)(c) O (n^2+ n1)(d) Ɵ (n)This interesting question is from Suffix tree topic in chapter Trie of Data Structures & Algorithms IThis question was addressed to me during an internship interview.

Answer»

Right choice is (d) Ɵ (n)

EASIEST explanation - SUFFIX Tree ALLOWS fast string OPERATION. To check if a substring is present in a string of a length of n, the TIME complexity for such operation is found to be O (n). The time complexity for finding the longest substring that is repeated in a string is Ɵ (n).



Discussion

No Comment Found

Related InterviewSolutions