#graph
Depth-First Search (DFS)
Introduction Depth-First Search (DFS) is a fundamental graph traversal algorithm that explores as far as possible along each branch before backtracking. Think of it like exploring a maze by always taking the first path you see, going as deep as possible, then backtracking when you hit a dead end. DFS is essential for detecting cycles, topological sorting, finding connected components, and solving maze/puzzle problems. Unlike BFS which uses a queue, DFS uses a stack (or recursion, which implicitly uses the call stack). Read more →
November 19, 2025
Breadth-First Search (BFS)
Introduction Breadth-First Search (BFS) is a fundamental graph traversal algorithm that explores vertices level by level, visiting all neighbors of a vertex before moving to the next level. Think of it like ripples spreading out in water—you explore all vertices at distance 1, then distance 2, and so on. BFS is essential for finding shortest paths in unweighted graphs, level-order traversal of trees, and solving maze/puzzle problems. It uses a queue to maintain the order of exploration. Read more →
November 19, 2025
Graphs - Introduction
Introduction A graph is a non-linear data structure consisting of vertices (nodes) connected by edges. Unlike trees, graphs can have cycles, multiple paths between nodes, and connections in any direction. Graphs model relationships and networks, making them fundamental to solving real-world problems in social networks, maps, computer networks, and more. Graphs are one of the most versatile and powerful data structures in computer science. By the end of this tutorial, you’ll understand graph terminology, types of graphs, representation methods, and when to use them. Read more →
November 19, 2025