DSA in Python – Shortest Path in Undirected Graph with Unit Distance | BFS | GFG | Part 142 [Hindi]
2.2K views on YouTube
🚀 Welcome to Part 142 of Code & Debug’s DSA in Python Course!
In this session, we solve the problem Shortest Path in an Undirected Graph with Unit Distance from GFG using the Breadth-First Search (BFS) algorithm.
This is a classic single-source shortest path problem where edge weights are 1, making BFS the most efficient approach.
🔍 What you’ll learn in this video:
✅ Why BFS works best for graphs with unit weights
✅ How to initialize distance array properly
✅ BFS traversal for minimum path discovery
✅ Handling disconnected nodes (distance = -1)
✅ Complete time & space complexity breakdown
📄 GFG Problem Link:
https://www.geeksforgeeks.org/problems/shortest-path-in-undirected-graph-having-unit-distance/1
👉 Refer to the article for better understanding:
🔗 https://codeanddebug.in/blog/shortest-path-in-an-undirected-graph/
📚 Python DSA Course Playlist with Sheet:
https://docs.google.com/spreadsheets/d/1AWE15Fy3wD2iqu2vjK_R7cCiuvSsjYQclcdZmHpF66o/edit?usp=sharing
🧠 Zero to Hero DSA Course:
https://codeanddebug.in/course/zero-to-hero-python-dsa
🧩 Leetcode-Based DSA Masterclass (Free):
https://codeanddebug.in/course/master-dsa-with-leetcode
👍 Like, 🔁 Share, 💬 Comment your doubts, and 🔔 Subscribe for more such DSA breakdowns!
#ShortestPath #BFS #GraphAlgorithms #UndirectedGraph #GFG #PythonDSA #CodeAndDebug #Part142 #SingleSourceShortestPath #UnitDistanceGraph