Algorithms and Complexity MCQs (Part-6)

What is the time complexity of Binary Search?

A O(n)
B O(log n)
C O(n log n)
D O(1)

Which algorithm is used for string matching?

A Merge Sort
B Binary Search
C Rabin-Karp
D Quick Sort

Which of the following is true about Interpolation Search?

A Works on sorted arrays
B Uses recursion
C Uses binary division
D Works on unsorted arrays

What is the primary disadvantage of Linear Search?

A Requires recursion
B Only works on sorted arrays
C Cannot handle duplicates
D High time complexity

Which algorithm is known for its worst-case time complexity of O(n^2)?

A Binary Search
B Naive String Matching
C Rabin-Karp
D Interpolation Search

What is the time complexity of the KMP (Knuth-Morris-Pratt) string matching algorithm?

A O(n)
B O(n log n)
C O(n^2)
D O(log n)

Which of the following is true about Binary Search?

A It works on unsorted arrays
B It uses a linear scan
C It requires sorted arrays
D It works on linked lists

What is the space complexity of Binary Search?

A O(n)
B O(1)
C O(log n)
D O(n log n)

Which algorithm is used to find the longest prefix-suffix in string matching?

A Rabin-Karp
B Binary Search
C Interpolation Search
D KMP

What is the advantage of using Rabin-Karp over other string matching algorithms?

A Better for small datasets
B Handles large alphabet sizes efficiently
C Handles multiple pattern matches efficiently
D Works without hashing

What type of data does Interpolation Search work best with?

A Uniformly distributed data
B Random data
C Data with fixed patterns
D Unsorted data

Which algorithm improves the time complexity of Naive String Matching?

A Quick Sort
B Rabin-Karp
C KMP
D Merge Sort

Which algorithm is commonly used for string matching in text?

A Binary Search
B KMP
C Merge Sort
D Quick Sort

What is the space complexity of the Floyd-Warshall algorithm?

A O(n)
B O(n^3)
C O(n^2)
D O(log n)

What is the key advantage of Divide and Conquer algorithms?

A Recursively divides problems into smaller subproblems
B Works only with small problems
C Solves problems sequentially
D Requires large memory