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?
- A. Binary heap: O(V^2); Fibonacci heap: O(E log E)
- B. Binary heap: O(E + V); Fibonacci heap: O(E^2)
- C. Binary heap: O(E log V); Fibonacci heap: O(E + V log V)
- 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
- Problem: For a set of 40 items split into two halves of 20, the meet-in-the-middle approach solves subset-sum queries in roughly which time?
- Problem: Grundy numbers for the subtraction game where a move removes 1 or 2 stones: what are g(0) through g(5)? Run the code. python g =…
- Problem: Using the bubble sort rule, what is the array after exactly one left-to-right pass over [3, 1, 2]? Run the code. python a = [3…
- Problem: How many legal moves does a knight have from the corner (0,0) of an 8 x 8 board? Run the code. python moves = [(1, 2), (2, 1)…
- Problem: What is 7^222 mod 10? Run the code. python print(pow(7, 222, 10)) What is printed?
- Problem: How many integers in [1, 500] are divisible by 4 or by 6? Run the code. python print(sum(1 for x in range(1, 501) if x % 4 == 0…