KMP Algorithm

1. Which of the following is the best description of a substring?
Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

2. Which of the following is not a prefix of the string "algorithm"?
Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

3. Which of the following is a suffix of the string "vlabs"?
Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

4. Which of the following best describes the purpose of the LPS (Longest Prefix Suffix) array in the KMP algorithm?
Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

5. What is the time complexity of the following recursive function?

          def f(n):
              if n == 0 or n == 1:
                  return 1
              return f(n-1) + f(n-2)
Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

6. Which of the following is NOT a valid step in the KMP preprocessing phase?
Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

Explanation

Explanation