Data Structures & AlgorithmsHardProduct Company SDE · graph round
Problem: Which statement about Dijkstra's algorithm using a binary heap with lazy deletion (pushing duplicate entries and skipping stale ones) is correct?
- A. It runs in O(E log E), which equals O(E log V) since E is at most V^2
- B. It requires a decrease-key operation, so the heap must be indexed
- C. It is correct only on unweighted graphs
- D. It runs in O(V^2) regardless of E
Correct answer: A. It runs in O(E log E), which equals O(E log V) since E is at most V^2
Lazy deletion pushes at most E entries, and log E is O(log V) when E is at most V^2. A decrease-key operation is not needed, which removes a common implementation complication.
More Coding Interview Problems questions
- Problem: What does the following print? python x = 5 print(x << 3 | x >> 1, x & 6, x ^ 3)
- Problem: For the string 'mississippi', what is the number of distinct substrings of length 2 that occur at least twice? Run the code…
- Problem: How many Armstrong numbers (numbers equal to the sum of their digits each raised to the power of the digit count) lie in [1…
- Problem: In how many ordered ways can 10 be written as a sum of parts from {1, 2, 3}, where the order of the parts matters? Run the code…
- Problem: How many subsets (including the empty subset) of [1, 2, 3] have XOR equal to 0? Run the code. python a = [1, 2, 3] print(sum(1…
- Problem: What does the following print? python print(bin(10).count('1'), (10).bitlength())