Unit 2: String Matching Algorithms and Computational Geometry - Subjective Questions

CSE408 — Design And Analysis Of Algorithms • Practice Questions with Detailed Answers

20 questions

1

Define sequential search. Describe its algorithm and analyze its best-case, worst-case, and average-case time complexities.

2

Explain how sequential search can be improved using the sentinel technique. State its advantages and complexity.

3

Describe the brute-force string-matching algorithm. Derive the maximum number of character comparisons made for a text of length and a pattern of length .

4

Write the naive pattern-matching algorithm that reports all occurrences of a pattern in a text. Explain how it handles overlapping occurrences.

5

Distinguish between sequential search and naive pattern matching with respect to input, comparison process, output, and time complexity.

6

Explain the Rabin-Karp string-matching algorithm and the role of hashing in it. Differentiate between a hash hit and a valid match.

7

Derive the rolling-hash update formula used by the Rabin-Karp algorithm. Explain the meaning of each term.

8

Analyze the expected and worst-case performance of the Rabin-Karp algorithm. Under what circumstances is Rabin-Karp particularly useful?

9

What is the prefix function or LPS array used in the Knuth-Morris-Pratt algorithm? Construct the LPS array for the pattern ABABCABAB.

10

Describe the Knuth-Morris-Pratt string-matching algorithm. Explain how it avoids redundant comparisons and prove its time complexity.

11

Explain how the LPS array is constructed efficiently for a pattern of length . Why does its construction require only time?

12

Compare the naive pattern-matching, Rabin-Karp, and Knuth-Morris-Pratt algorithms in terms of strategy, preprocessing, complexity, and applications.

13

Discuss important data structures used for string processing. Compare arrays, hash tables, tries, suffix trees, and suffix arrays.

14

Define a trie or prefix tree. Explain insertion, search, and deletion operations along with their time complexities.

15

Explain how a trie supports prefix searching and autocomplete. Compare array-based and map-based representations of trie nodes.

16

Define the closest-pair problem in computational geometry. Describe the brute-force solution and analyze its complexity.

17

Describe the divide-and-conquer algorithm for the two-dimensional closest-pair problem and derive its time complexity.

18

Why is it sufficient to compare each point with only a constant number of following points in the strip step of the closest-pair algorithm?

19

Define the convex hull of a set of planar points. Explain its important properties and applications.

20

Explain the Graham scan algorithm for finding the convex hull. Describe the orientation test and derive the algorithm's time complexity.