Questions
57 of 59
1What is a Graph? Define Vertex, Edge, Degree.
2What is the difference between Directed and Undirected Graphs?
3What is a Weighted Graph?
4What is a Cyclic vs Acyclic Graph?
5What is the difference between a Tree and a Graph?
6Explain Adjacency Matrix. What are its pros and cons?
7Explain Adjacency List. What are its pros and cons?
8Which representation is better for Sparse vs Dense graphs?
9Explain Breadth-First Search (BFS). What data structure does it use?
10Explain Depth-First Search (DFS). What data structure does it use?
11What is the time complexity of BFS and DFS?
12What is Topological Sorting? Which algorithm is used?
13How do you detect a cycle in a Directed Graph?
14How do you detect a cycle in an Undirected Graph?
15Explain Dijkstra's Algorithm. When does it fail?
16Explain Bellman-Ford Algorithm. Why is it slower than Dijkstra?
17What is the difference between Dijkstra and A* (A-star)?
18What is a Minimum Spanning Tree (MST)?
19Explain Kruskal's Algorithm. Which data structure is crucial for it?
20Explain Prim's Algorithm.
21What is the difference between Kruskal's and Prim's? When is one preferred?
22What is Union-Find (Disjoint Set Union)? Explain Path Compression and Union by Rank.
23What is a Bipartite Graph? How do you check for it?
24How do you find the shortest path in an unweighted graph?
25Explain Strongly Connected Components (Kosaraju/Tarjan).
26What is a Directed Acyclic Graph (DAG)? Why are they important in build systems?
27How do you solve a Maze using Graph algorithms?
28Explain Floyd-Warshall Algorithm (All Pairs Shortest Path).
29How do you detect a Deadlock using a Graph?
30What is the difference between Linear Search and Binary Search?
31What is the precondition for Binary Search?
32Write down the time complexities of Bubble, Selection, Insertion Sort.
33Why is Insertion Sort preferred for small or nearly sorted arrays?
34Explain Merge Sort. What is its time and space complexity?
35Explain Quick Sort. What is its worst-case complexity? How do you avoid it?
36Compare Merge Sort vs Quick Sort. When do you choose which?
37What is Heap Sort? How does it work?
38Is Heap Sort stable? Is Merge Sort stable?
39What is Counting Sort? What are its limitations?
40What is Radix Sort? How does it handle strings?
41What is the fastest possible time complexity for a comparison-based sort? Why?
42What is the difference between Internal and External Sorting?
43How do you find the k-th largest element in an array?
44How do you find the median of a stream of numbers?
45What is a Bucket Sort? When is it effective?
46Explain the concept of Stability in sorting. Why does it matter for multi-key sorting?
47What is a Persistent Data Structure?
48What is a Treap? How does it combine BST and Heap properties?
49What is a Bloom Filter? How do you calculate the False Positive rate?
50What is an LRU Cache? How do you implement it using a Hash Map and Doubly Linked List?
51What is an LFU Cache? How is it different from LRU?
52What is a Suffix Tree/Array? What string problems does it solve?
53What is a Van Emde Boas tree?
54How do you design a Data Structure that supports insert, delete, search, and getRandom in O(1)?
55What is the Median of Medians algorithm? Why is it better than random pivot selection?
56Explain the concept of Cache Oblivious algorithms.
57What is the difference between a Binary Heap and a Fibonacci Heap? Why is Fibonacci Heap theoretically faster for Dijkstra's?
58How are Data Structures used in Database Indexing? (B+ Trees, Hash Indexes)
59How does the Garbage Collector interact with data structures? (Weak references, Gen0/Gen1/Gen2)
57 / 59

What is the difference between a Binary Heap and a Fibonacci Heap? Why is Fibonacci Heap theoretically faster for Dijkstra's?

Difficulty: 7/10
heap data structures, priority queue operations, algorithm complexity

Binary Heap vs Fibonacci Heap

A binary heap provides O(log n) insertion and decrease-key and O(log n) deletion, with O(1) minimum access. A Fibonacci Heap supports O(1) amortized insertion and decrease-key, while delete-min is O(log n) amortized. Because Dijkstra performs many decrease-key operations, Fibonacci Heap improves the theoretical bound when used with the appropriate graph representation.

javascript
  1. 1

    Binary heap is simpler and usually has better practical constants.

  2. 2

    Fibonacci Heap has excellent amortized decrease-key complexity.

  3. 3

    Dijkstra with Fibonacci Heap: O(E + V log V).

  4. 4

    Binary heap Dijkstra is typically O((V+E) log V).

  5. 5

    Fibonacci Heaps are complex and often less attractive in production.

Scenario Questions

0-2 years experience

  1. 1If you need to implement a priority queue for a simple scheduler that only supports insert and extract‑min, which heap would you choose and why?
  2. 2Suppose you have an array of 100 integers and you build a binary heap in place. What happens to the heap property if you swap the root with the last element without re‑heapifying?
  3. 3How would you use a binary heap to find the k smallest elements in a stream of numbers?

2-5 years experience

  1. 1Your team replaced a binary heap with a Fibonacci heap in the Dijkstra implementation, but the runtime got worse on small graphs. What could be causing the slowdown?
  2. 2While debugging a routing service, you notice that decrease‑key operations are taking longer than expected. How would you verify whether the heap implementation is the bottleneck?
  3. 3You need to support frequent edge‑weight updates in a graph algorithm. Explain the trade‑offs between using a binary heap versus a Fibonacci heap for the priority queue.

5-8 years experience

  1. 1Design the priority‑queue component of a large‑scale navigation system that must handle millions of concurrent shortest‑path queries. How would you decide between binary and Fibonacci heaps, and what hybrid approach might you use?
  2. 2When scaling Dijkstra’s algorithm across a distributed cluster, what heap‑related issues arise, and how would you mitigate them?
  3. 3If you had to refactor an existing codebase that uses a binary heap to improve amortized performance for many decrease‑key calls, what architectural changes would you make and what risks would you watch for?

8+ years experience

  1. 1Your company is migrating a legacy routing engine that uses binary heaps to a new platform that prefers Fibonacci heaps for theoretical speed. How would you plan the migration to minimize regression risk and maintain cross‑team compatibility?
  2. 2At an organization level, how would you evaluate whether adopting Fibonacci heaps in core graph libraries is worth the engineering overhead, considering future feature roadmaps and hardware trends?
  3. 3Explain how you would instrument and monitor heap performance in production to decide if the theoretical advantages of Fibonacci heaps are realized in real traffic.

Follow-up Questions

  • Can you walk me through the amortized cost analysis for decrease‑key in a Fibonacci heap?
  • What practical factors might cause a Fibonacci heap to underperform its theoretical bound?
  • How would you test that your decrease‑key implementation is correct and efficient?
Share

Share via WhatsApp, X, Facebook, LinkedIn or copy link. Open Graph preview enabled.