Data Structures & AlgorithmsHardGoogle · Flipkart interview
What is the running time of Dijkstra's algorithm with a Fibonacci heap on a graph with V vertices and E edges?
- A. O((V + E) log V)
- B. O(E + V log V)
- C. O(V²)
- D. O(E log E)
Correct answer: B. O(E + V log V)
decrease-key is O(1) amortised in a Fibonacci heap, so the E relaxations cost O(E), while V extract-min operations cost O(log V) each. A binary heap gives O((V + E) log V), and the array version O(V²), which is better for very dense graphs than a binary heap.
More Coding Interview Problems questions
- For an array of n = 10⁶ integers, report the number of DISTINCT values in every window of k = 10⁵ consecutive elements. Which approach is…
- n = 10⁵ points are given, followed by q = 10⁵ OFFLINE queries 'how many points lie in the axis-aligned rectangle [x1, x2] × [y1, y2]?'…
- Edge case: integer division and modulo with negative operands in Python. python print(-7 // 2, -7 % 2, int(-7 / 2)) What is printed?
- Problem: Replace at most k characters so that the longest possible substring consists of one repeated letter; return its length. python…
- Problem: Smallest length of a contiguous subarray of POSITIVE integers with sum ≥ target (0 if none). python def minlen(a, t): l, s, best…
- Problem: Return all start indices of anagrams of p inside s using a fixed-size window of letter counts. python from collections import…