Unit 8: Pattern Matching - Subjective Questions

ECAP538 • Practice Questions with Detailed Answers

20 questions

1

Define the pattern matching problem. Explain its input, expected output, and major applications.

2

Explain the important considerations involved in designing an efficient pattern matching algorithm.

3

Describe the brute-force pattern matching algorithm with suitable pseudocode.

4

Prove the correctness of the brute-force pattern matching algorithm.

5

Analyze the best-case, worst-case, and space complexity of the brute-force pattern matching algorithm.

6

Trace the brute-force algorithm for text AABAACAADAABAABA and pattern AABA. State all matching positions.

7

Define the prefix function or LPS array used in the Knuth-Morris-Pratt algorithm. Why is it useful?

8

Construct the LPS array for the pattern AABAACAABAA and explain the construction.

9

Describe the Knuth-Morris-Pratt pattern matching algorithm with pseudocode.

10

Explain why the KMP algorithm does not miss any valid occurrence after shifting the pattern on a mismatch.

11

Derive the time and space complexity of the KMP algorithm.

12

Trace KMP for text ABABDABACDABABCABAB and pattern ABABCABAB.

13

Explain how KMP detects overlapping pattern occurrences. Illustrate with text AAAAA and pattern AAA.

14

Explain the bad-character heuristic of the Boyer-Moore algorithm.

15

Construct the bad-character table for the pattern NEEDLE and show how it determines a shift.

16

Describe the good-suffix heuristic used by the Boyer-Moore algorithm.

17

Describe the complete Boyer-Moore matching procedure and analyze its performance.

18

Trace the bad-character version of Boyer-Moore for text ABAAABCD and pattern ABC.

19

Compare the brute-force, KMP, and Boyer-Moore pattern matching algorithms.

20

Distinguish between the mismatch handling strategies of brute force, KMP, and Boyer-Moore.