Data Structures & AlgorithmsVery hardICPC regional · shortest paths
Problem: Which best describes the complexity of Dijkstra on a graph with V = 10^5 and E = 10^6 using an array instead of a heap?
- A. O(E log V), about 2 * 10^7 operations
- B. O(V^2 + E), about 10^10 operations
- C. O(V), about 10^5 operations
- D. O(E), about 10^6 operations
Correct answer: B. O(V^2 + E), about 10^10 operations
The array version scans all V vertices per extraction, so it costs about V^2 = 10^10 in total.
More Coding Interview Problems questions
- Problem: What is the Stern-Brocot tree's relevance to competitive programming?
- Problem: Which algorithm finds all integer points on the convex hull boundary of a set of points?
- Problem: What is the purpose of the 'sqrt decomposition' technique for an array?
- Problem: Which statement about the 'Chinese remainder theorem' is correct for non-coprime moduli?
- Problem: What is the complexity of computing the Euler totient for all numbers up to n with a linear sieve?
- Problem: Which technique computes the sum of a function over all subsets of a set of size n in O(n 2^n)?