---
title: "Discussion on \"BFS vs DFS: How to Pick the Right Graph Traversal\" | Hashnode"
description: "Discussion on \"BFS vs DFS: How to Pick the Right Graph Traversal\". BFS vs DFS, decided by invariants: the queue guarantees shortest paths, the stack exposes cycles and ordering. Know which traversal any problem needs."
url: "https://hashnode.com/posts/bfs-vs-dfs-how-to-pick-the-right-graph-traversal/6a10b6481f237623ea2e84f1"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [BFS vs DFS: How to Pick the Right Graph Traversal](https://codeintuition.hashnode.dev/bfs-vs-dfs-how-to-pick-the-right-graph-traversal?utm_source=hashnode&utm_medium=feed)

BFS vs DFS, decided by invariants: the queue guarantees shortest paths, the stack exposes cycles and ordering. Know which traversal any problem needs.

May 22 · 5 min read · codeintuition.hashnode.dev  
Read the article

-   [#leetcode](https://hashnode.com/tag/leetcode)
-   [#interview](https://hashnode.com/tag/interview)
-   [#algorithms](https://hashnode.com/tag/algorithms)
-   [#dsa](https://hashnode.com/tag/dsa)
-   [#codeintuition](https://hashnode.com/tag/codeintuition)
-   [#programming-blogs](https://hashnode.com/tag/programming-blogs)
-   [#beginners](https://hashnode.com/tag/beginners)

## Written by

[Prakhar Srivastava](https://hashnode.com/@prakhar-srv)

@prakhar-srv · London, UK

  
[View profile](https://hashnode.com/@prakhar-srv)

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
