Match each algorithm with its running time. (A) Breadth-first search, (B) Rabin–Karp algorithm, (C) Depth-first search, (D) Heap sort (worst case), (E) Quick sort (worst case). Times: (I) Θ(V + E), (II) O(V + E), (III) Θ((n − m + 1)m), (IV) O(n²), (V) O(n log n).
Pick an option to check yourself, or open the answer below.
Show answer & explanation
Correct answer: C. (A)-(II), (B)-(III), (C)-(I), (D)-(V), (E)-(IV)
Explanation
CLRS states BFS as O(V + E) and DFS as Θ(V + E); Rabin–Karp's worst case is Θ((n − m + 1)m); heap sort is O(n log n) in the worst case; quick sort's worst case is O(n²).
Note: As printed, options B and C are identical, so either is correct; the official key is C.
More Data Structures and Algorithms questions
- Statement I: Vertex cover has a polynomial-time 2-approximation algorithm. Statement II: TSP-tour is a polynomial-time 3-approximation algo…
- The postfix form of the expression (A + B) * (C * D - E ) * F /G is _______
- A double‐ended queue (dequeue) supports adding and removing items from both the ends of the queue. The operations supported by dequeue are…
- Two balanced binary trees are given with m and n elements, respectively. They can be merged into a balanced binary search tree in ____ time.
- A data structure is required for storing a set of integers such that each of the following O(log n) operations can be done in time, where n…
- Consider the following graph. Among the following sequences I. a b e g h f II. a b f e h g III. a b f h g e IV. a f g h b e Which are depth…