Computer Science - Data Structures - Graph traversal (BFS/DFS) - BFS and DFS Algorithms

4 sections. Section 1 'DFS - Depth First Search': Uses a stack (or recursion). Go as deep as possible, then backtrack. def dfs(graph, start): visited = set(); stack = [start]; while stack: node = stack.pop(); if node not in visited: visited.add(node); for neighbor in graph[node]: stack.append(neighb

Edodovivmagarwal
Computer Science - Data Structures - Graph traversal (BFS/DFS) - BFS and DFS Algorithms
Log in

Preparing your experience...

Loading scripts and resources

Comments (0)

0/5000

Comments are reviewed before appearing publicly.

About this Experience

Computer Science - Data Structures - Graph traversal (BFS/DFS) - BFS and DFS Algorithms

vivmagarwal
vivmagarwalJan 29, 2026

Description

4 sections. Section 1 'DFS - Depth First Search': Uses a stack (or recursion). Go as deep as possible, then backtrack. def dfs(graph, start): visited = set(); stack = [start]; while stack: node = stack.pop(); if node not in visited: visited.add(node); for neighbor in graph[node]: stack.append(neighb

Details

Computer ScienceData StructuresClass 12, Class 12, Grade 12, A2 Level, DP Year 2

Engagement

14

Likes

0

Remixes

0

Comments