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 MCQs Naive Pattern Search

CSE329 — Prelude To Competitive Coding 60 questions. Pick an option to check it.

Read the notes Subjective questions

0 of 60 answered 0 right 0 wrong , 60 left

  1. Question 1 of 60 The ubiquitous naïve pattern search problem Easy

    In the naïve pattern searching algorithm, the pattern is compared with the text starting at every possible position. What is the worst-case time complexity for a text of length and pattern of length ?

  2. Question 2 of 60 The ubiquitous naïve pattern search problem Easy

    How many starting positions in the text does the naïve algorithm check for a text of length and pattern of length ?

  3. Question 3 of 60 KMP algorithm Easy

    What is the overall time complexity of the KMP (Knuth-Morris-Pratt) pattern matching algorithm for text length and pattern length ?

  4. Question 4 of 60 KMP algorithm Easy

    What auxiliary structure does the KMP algorithm precompute from the pattern to avoid redundant comparisons?

  5. Question 5 of 60 Rabin-Karp algorithm Easy

    Which technique is central to the Rabin-Karp pattern matching algorithm?

  6. Question 6 of 60 Rabin-Karp algorithm Easy

    In Rabin-Karp, when two substrings produce the same hash value but the actual characters differ, this event is called a:

  7. Question 7 of 60 Rabin-Karp algorithm Easy

    What is the average-case time complexity of the Rabin-Karp algorithm for text length and pattern length ?

  8. Question 8 of 60 Introduction to Suffix array Easy

    A suffix array of a string stores which of the following?

  9. Question 9 of 60 Introduction to Suffix array Easy

    How many suffixes does a string of length have?

  10. Question 10 of 60 Checking if two strings are rotations of each other Easy

    A common trick to check if string is a rotation of string is to verify that is a substring of:

  11. Question 11 of 60 Checking if two strings are rotations of each other Easy

    For two strings to possibly be rotations of each other, what must first be true?

  12. Question 12 of 60 Largest connected component on a grid Easy

    Which traversal techniques are commonly used to find the largest connected component in a grid?

  13. Question 13 of 60 Largest connected component on a grid Easy

    In a grid problem using 4-directional connectivity, a cell is connected to its neighbors in how many directions?

  14. Question 14 of 60 Check if a string is substring of another string Easy

    If pattern occurs somewhere inside text , then is called a __ of .

  15. Question 15 of 60 Check if a string is substring of another string Easy

    Is the empty string "" considered a substring of every string?

  16. Question 16 of 60 Longest prefix which is also a suffix Easy

    For the string "", what is the longest proper prefix that is also a suffix?

  17. Question 17 of 60 Longest prefix which is also a suffix Easy

    When computing the longest prefix which is also a suffix, why must it be a proper prefix/suffix?

  18. Question 18 of 60 Problems based on naive pattern search Easy

    Using naïve search, how many times does the pattern "" occur in the text ""?

  19. Question 19 of 60 Lexicographical sorting of strings with practice problems based on this concept Easy

    Which of the following lists is in correct lexicographical (dictionary) order?

  20. Question 20 of 60 Splitting a string into substrings with suitable practice problems Easy

    Splitting the string "" on the delimiter "" produces how many substrings?

  21. Question 21 of 60 The ubiquitous naïve pattern search problem Medium

    For a text of length and a pattern of length , what is the worst-case time complexity of the naïve pattern search algorithm?

  22. Question 22 of 60 The ubiquitous naïve pattern search problem Medium

    Which text-pattern pair triggers the worst-case behavior of naïve pattern matching?

  23. Question 23 of 60 KMP algorithm Medium

    In the KMP algorithm, what does the LPS (Longest Prefix Suffix) array store for each index of the pattern?

  24. Question 24 of 60 KMP algorithm Medium

    What is the overall time complexity of the KMP algorithm for text length and pattern length ?

  25. Question 25 of 60 KMP algorithm Medium

    For the pattern ABABAA, what is the correct LPS array?

  26. Question 26 of 60 Rabin-Karp algorithm Medium

    In the Rabin-Karp algorithm, why is a hash comparison alone insufficient to confirm a pattern match?

  27. Question 27 of 60 Rabin-Karp algorithm Medium

    What is the key advantage of using a rolling hash in Rabin-Karp?

  28. Question 28 of 60 Rabin-Karp algorithm Medium

    What is the average-case time complexity of Rabin-Karp for text length and pattern length with a good hash?

  29. Question 29 of 60 Introduction to Suffix array Medium

    What does a suffix array of a string store?

  30. Question 30 of 60 Introduction to Suffix array Medium

    For the string banana, which suffix comes first in its suffix array?

  31. Question 31 of 60 Checking if two strings are rotations of each other Medium

    A common trick checks if string B is a rotation of A by testing whether B is a substring of which string?

  32. Question 32 of 60 Checking if two strings are rotations of each other Medium

    Which pair of strings are rotations of each other?

  33. Question 33 of 60 Largest connected component on a grid Medium

    Which technique is most commonly used to find the largest connected component of cells in a grid?

  34. Question 34 of 60 Largest connected component on a grid Medium

    For a grid with rows and columns using 4-directional connectivity, what is the time complexity of a flood-fill solution?

  35. Question 35 of 60 Check if a string is substring of another string Medium

    Using naïve substring checking, how many starting positions must be examined when searching pattern of length in text of length ?

  36. Question 36 of 60 Check if a string is substring of another string Medium

    Which statement about the empty string as a pattern is correct?

  37. Question 37 of 60 Longest prefix which is also a suffix Medium

    For the string aabaaab, what is the length of the longest proper prefix that is also a suffix?

  38. Question 38 of 60 Longest prefix which is also a suffix Medium

    The 'longest prefix which is also a suffix' concept is directly used to build which structure?

  39. Question 39 of 60 Problems based on naive pattern search Medium

    To count all overlapping occurrences of a pattern in a text using naïve search, what should you do after finding a match at index ?

  40. Question 40 of 60 Lexicographical sorting of strings with practice problems based on this concept Medium

    When sorting the strings ["apple", "app", "apply"] lexicographically, what is the correct order?

  41. Question 41 of 60 The ubiquitous naïve pattern search problem Hard

    Consider naïve pattern searching of a pattern of length in a text of length . What text/pattern combination triggers the algorithm's absolute worst-case number of character comparisons?

  42. Question 42 of 60 KMP algorithm Hard

    For the pattern $P = $ aabaabaaa, what is the KMP failure/LPS array (longest proper prefix that is also suffix for each prefix)?

  43. Question 43 of 60 KMP algorithm Hard

    During KMP matching, when a mismatch occurs at pattern index (with ), what is the correct next action?

  44. Question 44 of 60 Rabin-Karp algorithm Hard

    In Rabin-Karp with a rolling hash, why can the worst-case time complexity degrade to despite the rolling hash being per shift?

  45. Question 45 of 60 Rabin-Karp algorithm Hard

    For rolling hash , the update when sliding one position removes the leading char and adds trailing . Which formula is correct?

  46. Question 46 of 60 Introduction to Suffix array Hard

    For the string $S = $ banana, what is the suffix array (starting indices, 0-based, sorted lexicographically)?

  47. Question 47 of 60 Introduction to Suffix array Hard

    Using the fastest practical construction (prefix-doubling with radix sort), what is the time complexity to build a suffix array for a string of length ?

  48. Question 48 of 60 Checking if two strings are rotations of each other Hard

    The standard trick to test if is a rotation of (equal lengths ) is to check whether is a substring of . Using KMP, what is the time and space complexity?

  49. Question 49 of 60 Checking if two strings are rotations of each other Hard

    Given $A = $ abcde, which of the following is NOT a rotation of ?

  50. Question 50 of 60 Largest connected component on a grid Hard

    For finding the largest connected component of 1s in an binary grid using DFS/BFS with 8-directional connectivity, what is the correct time complexity?

  51. Question 51 of 60 Largest connected component on a grid Hard

    When using a Union-Find (DSU) approach to compute the largest connected component in a grid, why is it sufficient to union each cell only with its right and bottom neighbors (for 4-connectivity)?

  52. Question 52 of 60 Check if a string is substring of another string Hard

    You must check if pattern ( chars) is a substring of text ( chars) with guaranteed worst-case linear time AND no risk of false positives from hashing. Which algorithm best fits?

  53. Question 53 of 60 Longest prefix which is also a suffix Hard

    For $S = $ abababab, what is the length of the longest proper prefix that is also a suffix?

  54. Question 54 of 60 Longest prefix which is also a suffix Hard

    The smallest period of a string of length equals , where is the longest proper prefix-suffix length. For $S = $ aabaaab (length 7) with , what is the smallest period, and does the string have a period dividing ?

  55. Question 55 of 60 Problems based on naive pattern search Hard

    You want to count overlapping occurrences of pattern in text using naïve search. After a match at position , how should the search index advance to correctly count overlaps?

  56. Question 56 of 60 Problems based on naive pattern search Hard

    Given text aaaaa and pattern aa, how many overlapping occurrences exist, and how many non-overlapping (greedy left-to-right) occurrences exist?

  57. Question 57 of 60 Lexicographical sorting of strings with practice problems based on this concept Hard

    To arrange a list of numbers as strings so their concatenation forms the largest possible number, which comparator should sort two strings and ?

  58. Question 58 of 60 Lexicographical sorting of strings with practice problems based on this concept Hard

    When sorting the strings ["3", "30", "34", "5", "9"] to form the largest number, what is the resulting concatenation?

  59. Question 59 of 60 Splitting a string into substrings with suitable practice problems Hard

    Consider partitioning a string of length into contiguous substrings such that each substring is a palindrome, and you want the minimum number of cuts. What is the time complexity of the standard DP solution?

  60. Question 60 of 60 Splitting a string into substrings with suitable practice problems Hard

    You must count the number of ways to split a binary string into non-empty substrings such that each part, read as binary, is a power of . Which algorithmic technique most directly gives an efficient solution?

That's unit 5

Answer a few questions and your score shows up here.