📢 Too many exams? Don’t know which one suits you best? Book Your Free Expert 👉 call Now!


    Question

    The Rabin-Karp algorithm uses which technique to

    efficiently compare substrings?
    A Suffix arrays. Correct Answer Incorrect Answer
    B Finite automata. Correct Answer Incorrect Answer
    C Hashing. Correct Answer Incorrect Answer
    D Dynamic programming. Correct Answer Incorrect Answer
    E Greedy approach. Correct Answer Incorrect Answer

    Solution

    The Rabin-Karp algorithm uses hashing to quickly filter out positions in the text that are unlikely to match the pattern. It computes a hash value for the pattern and then computes hash values for all possible substrings of the text of the same length as the pattern. If the hash values match, it then performs a character-by-character comparison to confirm a true match (to handle hash collisions).

    Practice Next
    ask-question