Skip to content
ExamRizzInterview readingReading
Leave

STEM · Computer Science · Foundational Concepts/Principles

Save

Graphs and Graph Algorithms

Significance: Graphs model relationships: social networks, transportation, web pages, dependencies, state spaces. Fundamental algorithms: traversal (DFS, BFS), shortest paths (Dijkstra, Bellman-Ford, Floyd-Warshall), minimum spanning trees (Kruskal, Prim), network flow, topological sort. Many problems reduce to graph problems.

Questions to think through

  1. Apply Dijkstra's algorithm: Find shortest path from A in weighted graph. Dijkstra maintains distances to each node, repeatedly selecting unvisited node with minimum distance. Trace algorithm on example graph. Why does greedy selection work (optimal substructure)? What's time complexity: O((V+E) log V) with binary heap. Why doesn't it work with negative edges (violates greedy assumption)?

    explain
  2. Design graph algorithm: Detect cycle in directed graph. DFS approach: maintain states (unvisited, visiting, visited). When visiting node, explore neighbors. If neighbor is "visiting" (in current path), cycle exists. If "visited" (completed subtree), no cycle via that path. Explain why this works. What's time complexity O(V+E)? Convert this to detect strongly connected components (Kosaraju or Tarjan's algorithm).

    explain

Graph Theory · Graph Algorithms · Dijkstra's Algorithm · DFS · BFS · Shortest Path · Network Analysis