Unit 2 - Practice Quiz

CSE408 60 Questions
0 Correct 0 Wrong 60 Left
0/60

1 What is the primary characteristic of the brute-force string matching algorithm?

Sequential Search and Brute-Force String Matching Easy
A. It requires the text to be sorted.
B. It uses hash functions.
C. It compares the pattern with every possible substring of the text.
D. It skips characters based on prefix-suffix matches.

2 What is the worst-case time complexity of sequential search on an array of elements?

Sequential Search and Brute-Force String Matching Easy
A.
B.
C.
D.

3 What does the Closest-Pair problem aim to find?

Closest-Pair and Convex-Hull Problem Easy
A. The two points in a set with the minimum distance between them.
B. The boundary points of a set.
C. The center of the point set.
D. The two points in a set that are furthest apart.

4 Which real-world object is often used to describe a Convex Hull?

Closest-Pair and Convex-Hull Problem Easy
A. A spider web.
B. A labyrinth.
C. A rubber band stretched around a set of pegs.
D. A chess board.

5 What is Exhaustive Search?

Exhaustive Search Easy
A. An algorithm that divides the problem into smaller subproblems.
B. A technique used only for sorted arrays.
C. A method that uses heuristics to find a quick solution.
D. A problem-solving approach that evaluates all possible solutions.

6 What does a Voronoi diagram partition a plane into?

Voronoi Diagrams Easy
A. Concentric circles.
B. Regions based on distance to a specific set of points.
C. Triangles.
D. Squares.

7 The Naive String-Matching Algorithm is equivalent to which of the following?

Naiva String-Matching Algorithm Easy
A. Boyer-Moore Algorithm
B. Brute-Force String Matching
C. Knuth-Morris-Pratt Algorithm
D. Rabin-Karp Algorithm

8 What is the worst-case time complexity of the Naive String-Matching algorithm for a text of length and pattern of length ?

Naiva String-Matching Algorithm Easy
A.
B.
C.
D.

9 Which technique is heavily utilized in the Rabin-Karp Algorithm to find string matches?

Rabin-Karp Algorithm Easy
A. Dynamic Programming
B. Divide and Conquer
C. Hashing
D. Greedy Approach

10 What is a 'spurious hit' in the context of the Rabin-Karp algorithm?

Rabin-Karp Algorithm Easy
A. When the pattern is exactly at the beginning of the text.
B. When the hash values match but the actual strings do not.
C. When the algorithm fails to compute the hash.
D. When the hash values do not match but the strings do.

11 What is the primary advantage of the Knuth-Morris-Pratt (KMP) algorithm over naive string matching?

Knuth-Morris-Pratt Algorithm Easy
A. It requires no preprocessing.
B. It avoids re-evaluating characters in the text that have already been matched.
C. It uses less memory.
D. It works on multiple patterns simultaneously.

12 What does the 'LPS' array in the KMP algorithm store?

Knuth-Morris-Pratt Algorithm Easy
A. The length of the longest palindrome.
B. The ASCII values of the pattern.
C. The hash values of the characters.
D. The length of the longest proper prefix which is also a suffix.

13 Which well-known problem is often solved using Exhaustive Search to evaluate all possible permutations?

Exhaustive Search Easy
A. Merge Sort
B. Binary Search
C. Shortest Path in a DAG
D. Traveling Salesperson Problem (TSP)

14 In sequential search, if the target element is the very first item in the list, what is this case known as?

Sequential Search and Brute-Force String Matching Easy
A. Average case
B. Best case
C. Base case
D. Worst case

15 Which of the following describes the shape of a Convex Hull?

Closest-Pair and Convex-Hull Problem Easy
A. A polygon with internal angles less than or equal to 180 degrees.
B. A straight line.
C. A circle.
D. A star-shaped polygon.

16 In a Voronoi diagram, the boundaries separating regions are formed by:

Voronoi Diagrams Easy
A. Randomly drawn straight lines.
B. Perpendicular bisectors of the segments joining neighboring points.
C. Lines connecting all points.
D. Circles drawn around the points.

17 Why does the Rabin-Karp algorithm use modulo arithmetic?

Rabin-Karp Algorithm Easy
A. To count the number of characters.
B. To sort the strings.
C. To prevent integer overflow when calculating large hash values.
D. To reverse the string.

18 What is the time complexity of the preprocessing phase in the KMP algorithm for a pattern of length ?

Knuth-Morris-Pratt Algorithm Easy
A.
B.
C.
D.

19 Which of the following is a major drawback of Exhaustive Search?

Exhaustive Search Easy
A. It is highly inefficient for large problem sizes.
B. It does not guarantee finding a solution.
C. It requires a sorted input.
D. It is difficult to implement.

20 What is the worst-case time complexity for a brute-force approach to solving the Closest-Pair problem for points?

Closest-Pair and Convex-Hull Problem Easy
A.
B.
C.
D.

21 In the Brute-Force string matching algorithm, what is the maximum number of character comparisons required to find a pattern of length in a text of length ?

Sequential Search and Brute-Force String Matching Medium
A.
B.
C.
D.

22 Which of the following scenarios represents the worst-case for the brute-force string matching algorithm?

Sequential Search and Brute-Force String Matching Medium
A. Text = "AAAAAAAA", Pattern = "B"
B. Text = "ABABABAB", Pattern = "B"
C. Text = "AAAAAAAA", Pattern = "AAAB"
D. Text = "ABCDEFGH", Pattern = "FGH"

23 What is the time complexity of solving the closest-pair problem using the divide-and-conquer approach?

Closest-Pair and Convex-Hull Problem Medium
A.
B.
C.
D.

24 In Quickhull algorithm for finding the convex hull, which approach does it closely resemble?

Closest-Pair and Convex-Hull Problem Medium
A. Quick Sort
B. Insertion Sort
C. Heap Sort
D. Merge Sort

25 Which of the following problems is classically solved using an exhaustive search approach by evaluating all permutations?

Exhaustive Search Medium
A. Minimum Spanning Tree
B. Shortest Path Problem
C. Traveling Salesperson Problem (TSP)
D. Binary Search

26 Why is exhaustive search generally impractical for large inputs?

Exhaustive Search Medium
A. Its time complexity usually grows exponentially or factorially.
B. It requires complex data structures.
C. It uses too much memory space.
D. It often produces suboptimal results.

27 In a Voronoi diagram of a set of points in a 2D plane, what do the edges of the Voronoi polygons represent?

Voronoi Diagrams Medium
A. The convex hull of the point set
B. The shortest distance between two points
C. The perpendicular bisectors of the segments joining neighboring points
D. The paths connecting all points in minimum distance

28 What is the relationship between the Delaunay triangulation and the Voronoi diagram for a given set of points?

Voronoi Diagrams Medium
A. They are dual graphs of each other.
B. There is no relationship.
C. They are identical.
D. Delaunay triangulation is the complement of the Voronoi diagram.

29 If a pattern of length is matched against a text of length using the naive string matching algorithm, how many valid shifts are tested?

Naiva String-Matching Algorithm Medium
A.
B.
C.
D.

30 Which of the following is true regarding the naive string-matching algorithm?

Naiva String-Matching Algorithm Medium
A. It requires no extra memory and checks every possible shift.
B. It requires preprocessing of the pattern.
C. It skips certain shifts based on previous matches.
D. Its best-case time complexity is .

31 The Rabin-Karp algorithm uses hashing. What is the primary purpose of the rolling hash in this algorithm?

Rabin-Karp Algorithm Medium
A. To compute the hash of the next window in time.
B. To sort the characters of the pattern.
C. To detect duplicate characters in the text.
D. To avoid character comparisons entirely.

32 In the Rabin-Karp algorithm, what happens when a hash collision occurs (the hash of the pattern equals the hash of a text window)?

Rabin-Karp Algorithm Medium
A. The window is skipped.
B. The algorithm must perform a character-by-character comparison to confirm the match.
C. The pattern is found, and the algorithm terminates.
D. The hash function is recomputed with a new prime modulus.

33 What is the primary optimization that the Knuth-Morris-Pratt (KMP) algorithm provides over the naive string-matching algorithm?

Knuth-Morris-Pratt Algorithm Medium
A. It avoids re-evaluating characters in the text that have already matched.
B. It compresses the text before searching.
C. It hashes the text to speed up comparisons.
D. It searches from right to left instead of left to right.

34 In the KMP algorithm, what does the LPS (Longest Proper Prefix which is also Suffix) array store for a pattern?

Knuth-Morris-Pratt Algorithm Medium
A. The lengths of the longest proper prefix that matches a proper suffix for every sub-pattern.
B. The indices of non-matching characters.
C. The hash values of all prefixes.
D. The distance to the next identical character.

35 Compute the LPS (Longest Proper Prefix which is also Suffix) array for the pattern "ABABC".

Knuth-Morris-Pratt Algorithm Medium
A. [0, 0, 1, 2, 1]
B. [0, 0, 0, 0, 0]
C. [0, 0, 1, 2, 0]
D. [0, 1, 2, 3, 0]

36 Which of the following is true about Brute-Force string matching?

Sequential Search and Brute-Force String Matching Medium
A. It is the most optimal string matching algorithm in all cases.
B. It performs better than KMP for highly repetitive patterns.
C. It can backtrack the text pointer after a mismatch.
D. It requires a preprocessing phase.

37 In the divide-and-conquer algorithm for the Closest-Pair problem, during the combine step, how many points in the strip at most need to be checked for a given point?

Closest-Pair and Convex-Hull Problem Medium
A.
B. 7
C. 11
D. 2

38 What is the worst-case time complexity of the Rabin-Karp algorithm, and when does it occur?

Rabin-Karp Algorithm Medium
A. , when the text contains special characters.
B. , when there are no hash collisions.
C. , when the hash function uses large primes.
D. , when all window hash values match the pattern hash value.

39 What is the time complexity of the preprocessing step to build the LPS array in the KMP algorithm for a pattern of length ?

Knuth-Morris-Pratt Algorithm Medium
A.
B.
C.
D.

40 Which set of points uniquely defines the convex hull of a planar point set?

Closest-Pair and Convex-Hull Problem Medium
A. The extreme points that form the boundary of the smallest convex polygon enclosing all points.
B. The points that lie strictly inside the bounding box.
C. The points with the minimum and maximum x and y coordinates.
D. The collinear points in the set.

41 In the Brute-Force string matching algorithm, what is the exact maximum number of character comparisons required to find all occurrences of a pattern of length in a text of length , assuming overlapping occurrences are counted?

Sequential Search and Brute-Force String Matching Hard
A.
B.
C.
D.

42 Consider a text of length and a pattern of length where all characters are distinct. How many comparisons does the Brute-Force algorithm make in the worst case if is not in ?

Sequential Search and Brute-Force String Matching Hard
A.
B.
C.
D.

43 In the divide-and-conquer algorithm for the Closest-Pair problem, points in the strip of width are sorted by their -coordinates. What is the maximum number of points in the strip that need to be checked against a given point to guarantee finding a closer pair if it exists?

Closest-Pair and Convex-Hull Problem Hard
A. 7
B. 8
C. 6
D. 5

44 Which of the following is true regarding Graham's scan algorithm for finding the Convex Hull?

Closest-Pair and Convex-Hull Problem Hard
A. Its worst-case time complexity is when all points lie on a circle.
B. It computes the upper and lower hulls separately in time after sorting by -coordinate.
C. It requires sorting points by their polar angle, giving a total time complexity of .
D. It uses a divide-and-conquer strategy, merging two convex polygons in time.

45 When solving the Traveling Salesperson Problem (TSP) using exhaustive search on a complete graph with vertices, the number of distinct tours evaluated (ignoring starting vertex and direction) is:

Exhaustive Search Hard
A.
B.
C.
D.

46 What is the relationship between the Voronoi Diagram of a set of points and its Delaunay Triangulation?

Voronoi Diagrams Hard
A. The Voronoi Diagram connects the centroids of the triangles in the Delaunay Triangulation.
B. The Delaunay Triangulation is the straight-line dual graph of the Voronoi Diagram.
C. The Voronoi Diagram is a subgraph of the Delaunay Triangulation.
D. They are geometrically identical but represented differently in data structures.

47 In a Voronoi diagram for points in the plane (where and not all points are collinear), what is the maximum number of Voronoi vertices?

Voronoi Diagrams Hard
A.
B.
C.
D.

48 Consider the Naive String-Matching algorithm searching for pattern of length in text of length . If consists of 'A's followed by a 'B', and consists entirely of 'A's, what is the exact number of character comparisons made?

Naiva String-Matching Algorithm Hard
A.
B.
C.
D.

49 In the Rabin-Karp algorithm, spurious hits occur when the hash value of the pattern matches the hash value of a text substring, but the strings are not identical. If a prime modulus is chosen randomly from a suitable range, what is the expected number of spurious hits for a text of length and pattern of length ?

Rabin-Karp Algorithm Hard
A.
B.
C.
D.

50 Which mathematical property allows the Rabin-Karp algorithm to compute the hash value of the next substring from the current substring in time?

Rabin-Karp Algorithm Hard
A. The Chinese Remainder Theorem
B. Euclidean Algorithm
C. Fermat's Little Theorem
D. Modular arithmetic and Horner's rule

51 For the pattern , what is the prefix function (or array) computed in the Knuth-Morris-Pratt algorithm?

Knuth-Morris-Pratt Algorithm Hard
A.
B.
C.
D.

52 In the KMP algorithm, what is the maximum number of times the (prefix) function can backtrack (i.e., ) while processing a single character in the text?

Knuth-Morris-Pratt Algorithm Hard
A.
B.
C.
D.

53 When solving the subset-sum problem using exhaustive search on a set of elements, the state space tree has how many leaves?

Exhaustive Search Hard
A.
B.
C.
D.

54 Which algorithm computes the convex hull of points in time, where is the number of points on the convex hull, making it output-sensitive?

Closest-Pair and Convex-Hull Problem Hard
A. Quickhull
B. Divide and Conquer
C. Jarvis's March (Gift Wrapping)
D. Graham's Scan

55 If a Brute-Force string matcher searches for a pattern of length in text of length , what is the average-case time complexity assuming the text and pattern are generated randomly over an alphabet of size ?

Sequential Search and Brute-Force String Matching Hard
A.
B.
C.
D.

56 To prevent arithmetic overflow when computing the rolling hash in the Rabin-Karp algorithm, modulo arithmetic is used. What is the consequence if the modulus is NOT chosen to be a prime number?

Rabin-Karp Algorithm Hard
A. The time complexity for computing the hash increases to .
B. The algorithm will enter an infinite loop.
C. The probability of hash collisions may increase, leading to more spurious hits.
D. The rolling hash update formula will fail to compute the correct hash.

57 In the KMP algorithm, the prefix array is used to determine the next shift. If , what does this indicate during the matching process?

Knuth-Morris-Pratt Algorithm Hard
A. The algorithm has found the pattern in the text.
B. The pattern matches the text perfectly up to index .
C. There is no proper prefix of that is also a suffix, so the pattern must shift entirely past the current matched segment.
D. The character at index in the text must be skipped.

58 What is the computational complexity of constructing a Voronoi diagram of points using Fortune's sweep-line algorithm?

Voronoi Diagrams Hard
A.
B.
C.
D.

59 Consider solving the Assignment Problem for an cost matrix using exhaustive search. What is the asymptotic time complexity of evaluating all possible assignments?

Exhaustive Search Hard
A.
B.
C.
D.

60 In the 2D Closest-Pair problem divide-and-conquer algorithm, let be the minimum distance found in the left and right halves. Why do we only need to consider points within a horizontal distance of from the dividing line ?

Closest-Pair and Convex-Hull Problem Hard
A. Because calculating the distance for points further than causes floating-point overflow.
B. Because the Delaunay Triangulation ensures no closer points exist outside the strip.
C. Because points outside this vertical strip cannot form a convex hull.
D. Because any pair of points split across the dividing line with distance less than must have -coordinates differing by at most .