1.

What is the time required to locate the occurrences of a pattern P of length m in a string of length n using suffix array?(a) O(nm)(b) O(n^2)(c) O(mnlogn)(d) O(mlogn)My question comes from Arrays Types topic in portion Arrays Types of Data Structures & Algorithms IThe question was posed to me in an interview for internship.

Answer»

Right option is (d) O(mlogn)

EXPLANATION: Suffix arrays are used to FIND the occurrences of a pattern in a STRING. Pattern of length m will require m characters to compare, so USING suffix array we can find occurrences of a pattern in the string of length n in O(mlogn) time.



Discussion

No Comment Found

Related InterviewSolutions