Notice: Due to an ongoing migration of our storage and publishing system, material requested since last month will not be uploaded for the time being, and new requests are paused. All existing notes remain available.

Unit 5 subjective questions Naive Pattern Search

CSE329 — Prelude To Competitive Coding 20 questions with model answers. Write yours first, then compare.

Read the notes Practice MCQs
  1. Question 1 of 20

    Define the naïve pattern search problem. Explain the working of the naïve pattern searching algorithm with a suitable example.

  2. Question 2 of 20

    Explain the KMP (Knuth-Morris-Pratt) algorithm. How does it improve upon the naïve approach?

  3. Question 3 of 20

    What is the LPS (Longest Prefix Suffix) array in the KMP algorithm? Construct the LPS array for the pattern P = "ABABCABAB".

  4. Question 4 of 20

    Describe the Rabin-Karp algorithm for pattern searching. What role does hashing play in it?

  5. Question 5 of 20

    Compare the KMP algorithm and the Rabin-Karp algorithm in terms of approach, time complexity, and use cases.

  6. Question 6 of 20

    What is a Suffix Array? Explain how it is constructed and give its applications.

  7. Question 7 of 20

    Explain how to check if two strings are rotations of each other. Provide an efficient algorithm with an example.

  8. Question 8 of 20

    Describe the Largest Connected Component on a Grid problem. Explain the approach to solve it.

  9. Question 9 of 20

    Explain how to check whether one string is a substring of another using the naïve approach. Write the pseudocode and analyze its complexity.

  10. Question 10 of 20

    Explain the concept of Longest Prefix which is also a Suffix (proper prefix-suffix). How is it computed, and why is it important in string algorithms?

  11. Question 11 of 20

    Distinguish between a proper prefix, a proper suffix, and a border of a string with examples.

  12. Question 12 of 20

    Explain Lexicographical Sorting of strings. How does it differ from numerical sorting? Illustrate with an example.

  13. Question 13 of 20

    Describe how to split a string into substrings based on a delimiter. Discuss different approaches with examples.

  14. Question 14 of 20

    Derive the time complexity of the naïve pattern matching algorithm in the best, average, and worst cases with justification.

  15. Question 15 of 20

    Given the pattern P = "AABAACAABAA", construct the LPS array and trace how KMP uses it during a mismatch.

  16. Question 16 of 20

    In the Rabin-Karp algorithm, explain the concept of rolling hash and spurious hits. Why is a prime modulus used?

  17. Question 17 of 20

    Explain how a suffix array can be used to search for a pattern in a text. What is the time complexity of this search?

  18. Question 18 of 20

    Write an algorithm to find the shortest period of a string using the LPS array. Illustrate with the string "abcabcabc".

  19. Question 19 of 20

    Discuss common problems based on naive pattern search and explain how naïve search can still be useful despite its inefficiency.

  20. Question 20 of 20

    Write a program logic (pseudocode) to lexicographically sort a list of strings and explain a practice problem where lexicographical ordering is essential.

That's unit 5

Long answers stick best when they're tested again soon. Run the MCQs on this unit, then come back to the questions you found hardest.