Graph & tree vocabulary

  • BFS — breadth-first (queue); finds shortest path by hops; level-by-level
  • DFS — depth-first (stack/recursion); cycle detection; pre/in/post-order traversal
  • In-order — left→node→right; produces sorted output on a BST
  • Dijkstra's — shortest path by total edge weight; requires non-negative weights
  • Topological sort — DAG ordering; each node before its dependents (build systems, task queues)

Question 0 of 5

In a code review, a comment says: "This uses BFS to find the shortest path." What does BFS stand for and how does it work?