What is the pre-processing time of Rabin and Karp Algorithm?

Review the verified answer and explanation for this SPSC – Sindh Public Service Commission past-paper question on CampusFin.

What is the pre-processing time of Rabin and Karp Algorithm? Answer: Theta(m)

The pre-processing step in Rabin-Karp involves computing the hash of the pattern, which is of length m. This hashing takes Θ(m) time (i.e., linear time in the size of the pattern).

Question context

This question is part of 💻 Computing within the broader 💾 Computer Science subject and appears in the SPSC – Sindh Public Service Commission preparation collection. Reviewing the answer together with nearby questions helps reinforce the underlying concept and identify how it may appear in competitive exams.