Advanced Data Structures & Algorithms
Q97 / 100

What is the Z-algorithm for string processing?

Correct! Well done.

Incorrect.

The correct answer is B) An algorithm computing Z[i] = length of the longest substring starting at i that matches a prefix of the string, enabling O(n) pattern search

B

Correct Answer

An algorithm computing Z[i] = length of the longest substring starting at i that matches a prefix of the string, enabling O(n) pattern search

Explanation

The Z-array Z[i] gives the length of the longest common prefix between the string and its suffix starting at i. Concatenating pattern + "$" + text and computing Z[i] finds pattern occurrences in O(n + m).

Progress
97/100