+1 vote
in Data Structures & Algorithms II by (110k points)
What is the auxiliary space complexity of Z algorithm for pattern searching (m = length of text, n = length of pattern)?

(a) O(n + m)

(b) O(m)

(c) O(n)

(d) O(m * n)

I got this question in an online quiz.

I'm obligated to ask this question of Searching topic in division Searching of Data Structures & Algorithms II

1 Answer

+1 vote
by (614k points)
selected by
Best answer
Correct option is (b) O(m)

Easy explanation - Z algorithm is an efficient pattern searching algorithm as it searches the pattern in linear time. It an auxiliary space of O(m) for maintaining Z array.

Related questions

Welcome to TalkJarvis QnA, a question-answer community website for the people by the people. On TalkJarvis QnA you can ask your doubts, curiosity, questions and whatever going in your mind either related to studies or others. Experts and people from different fields will answer.