All mock tests are FREE till 31 December — register to save your progress
Unit 7 · Data Structures and Algorithms Paper 2 CS · September 2022

Consider the following algorithms and their running times. Which one of the following is correct?
List IList II
A. Breadth-first searchI. Θ(V + E)
B. Rabin–Karp algorithmII. O(V + E)
C. Depth-first searchIII. Θ((n − m + 1)m)
D. Heap sort (worst case)IV. O(n²)
E. Quick sort (worst case)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

BFS O(V + E); Rabin–Karp worst case Θ((n − m + 1)m); DFS Θ(V + E); heap sort worst O(n log n); quick sort worst O(n2).

More Data Structures and Algorithms questions