Escrito por estudiantes que aprobaron Inmediatamente disponible después del pago Leer en línea o como PDF ¿Documento equivocado? Cámbialo gratis 4,6 TrustPilot
logo-home
Notas de lectura

Data structure & algorithms (BFS & DFS notes)

Puntuación
-
Vendido
-
Páginas
40
Subido en
06-09-2025
Escrito en
2024/2025

This document provides a concise comparison and detailed explanation of the BFS (Breadth-First Search) and DFS (Depth-First Search) algorithms. It covers the basic concepts, high-level steps, and applications of each, including their role in solving the shortest path problem. The document also includes information on advanced topics like Dijkstra's and Bellman-Ford algorithms, their complexity analysis, and provides pseudocode for practical implementation. This is a valuable resource for students studying graph traversal algorithms.

Mostrar más Leer menos
Institución
Grado

Vista previa del contenido

Data Structures and Algorithm
(CC-2042)
Lecture 31
E N G R. D R B I L A L A S H FA Q A H M E D
S C H O O L O F S Y S T E M S A N D T E C H N O LO GY ( S S T )
C O M P U T E R S C I E N C E FA C U LT Y

,Breadth-First Search (BFS)
Breadth-First Search (BFS) is a fundamental graph traversal algorithm that
explores a graph in “layers.”
Key Concept
•Starting Point: You choose a source vertex.
•Layer-by-Layer Exploration:
• Visit all direct neighbors of the source (distance 1).
• Then, for each neighbor, visit their unvisited neighbors (distance 2), and so on
• This naturally proceeds in “layers” from the source.

This approach guarantees that you discover vertices in order of their distan
(in edges) from the source.



09/06/2025 DS

,How It Works (Algorithm Steps)
Initialization:
 Mark all vertices as “not visited.”
 Use a queue data structure to keep track of vertices to process.
Enqueue Source:
 Mark the source vertex as visited and enqueue it.
Main Loop:
 While the queue is not empty:
 Dequeue a vertex u.
 Process u (e.g., print it or record its order).
 For each unvisited neighbor v of u:
 Mark v as visited.
 Enqueue v.
Terminate when the queue is empty (no more vertices to explore).



09/06/2025 DS

, Shortest Path (Unweighted
Graph)
Distance Layers: In an unweighted graph, BFS naturally finds the shortes
number of edges between the source and every other reachable vertex.
Reason: By the time BFS reaches a vertex, it has taken the minimum
possible steps from the source (due to the layer-by-layer exploration).




09/06/2025 DS

Escuela, estudio y materia

Institución
Grado

Información del documento

Subido en
6 de septiembre de 2025
Número de páginas
40
Escrito en
2024/2025
Tipo
NOTAS DE LECTURA
Profesor(es)
Dr.bilal ashfaq
Contiene
Class no.12

Temas

$12.49
Accede al documento completo:

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF

Conoce al vendedor
Seller avatar
hafizhasc

Documento también disponible en un lote

Conoce al vendedor

Seller avatar
hafizhasc umt
Seguir Necesitas iniciar sesión para seguir a otros usuarios o asignaturas
Vendido
-
Miembro desde
6 meses
Número de seguidores
1
Documentos
19
Última venta
-

0.0

0 reseñas

5
0
4
0
3
0
2
0
1
0

Documentos populares

Recientemente visto por ti

Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes