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