Data Structures & AlgorithmsHardICPC regional · graph round

Problem: For Dijkstra on a graph with V vertices and E edges, which pairing of data structure and running time is correct?

  1. A. Binary heap: O(V^2); Fibonacci heap: O(E log E)
  2. B. Binary heap: O(E + V); Fibonacci heap: O(E^2)
  3. C. Binary heap: O(E log V); Fibonacci heap: O(E + V log V)
  4. D. Both are O(V^3) regardless of the heap

Correct answer: C. Binary heap: O(E log V); Fibonacci heap: O(E + V log V)

A binary heap gives O(E log V) through lazy or indexed updates, and a Fibonacci heap gives O(E + V log V) because decrease-key is amortised O(1). Confusing the two bounds is the typical slip.

More Coding Interview Problems questions

Exams that ask this topic