Academic Session 2025-26
ODD Semester Jul-Dec 2025
UNIVERSITY INSTITUTE OF ENGINEERING
COMPUTER SCIENCE ENGINEERING
Bachelor of Engineering
Semester: 6th
Design and Analysis of Algorithms
(23CSH-301/ITH-301)
Unit No. 1 Chapter No. 2 Lecture No. 11
Topic : Graphs
Richa Dhiman E11307 Assistant Professor
1
Learning Objectives & Outcomes
Objective:
• To understand the Graph and types of Graphs.
Outcome:
• Student will understand
Graph and its types.
2
Graph
• A Graph is a non-linear data structure consisting of
nodes and edges. The nodes are sometimes also
referred to as vertices and the edges are lines or arcs
that connect any two nodes in the graph.
• More formally a Graph can be defined as,
• A Graph consists of a finite set of vertices(or nodes) and
set of Edges which connect a pair of nodes.
3
• In the above Graph, the set of vertices V = {0,1,2,3,4} and
the set of edges E = {01, 12, 23, 34, 04, 14, 13}.
4
• Graphs are used to solve many real-life problems.
• Graphs are used to represent networks. The networks
may include paths in a city or telephone network or
circuit network.
• Graphs are also used in social networks like linkedIn,
Facebook. For example, in Facebook, each person is
represented with a vertex(or node). Each node is a
structure and contains information like person id, name,
gender, locale etc.
5
DFS
• DFS stands for Depth First Search is a edge based
technique. It uses the Stack data structure, performs two
stages, first visited vertices are pushed into stack and
second if there is no vertices then visited vertices are
popped.
Ex-
• Output is: A, B, D, C, E, F
6
BFS
• BFS stands for Breadth First Search is a vertex based
technique for finding a shortest path in graph. It uses a
Queue data structure which follows first in first out. In
BFS, one vertex is selected at a time when it is visited
and marked then its adjacent are visited and stored in
the queue. It is slower than DFS.
Output is:
A, B, C, D, E, F
7
Applications 8
•Social Networks
•Web Page Ranking (e.g., PageRank in search
engines)
•Computer Networks and Routing
•Geographic Information Systems (GIS) / Mapping
•Recommendation Engines
•Dependency Resolution (e.g., package managers,
build systems)
•Scheduling and Resource Allocation (e.g., task
graphs)
Summary 9
Introduction to Algorithm
• Characteristic of algorithm
• Needs and specification of algorithm
10
Next Lecture
Sorting in linear time: counting sort
11
Quiz
1.In a weighted graph with nonnegative weights, which algorithm finds
the shortest path from a single source to all other vertices?
A) Bellman-Ford
B) Dijkstra’s
C) Floyd-Warshall
D) Kruskal’s
2.Which of these is a property of a tree when considered as a graph?
A) It can contain cycles.
B) It has exactly V edges for V vertices.
C) It is a connected, acyclic undirected graph with V – 1 edges.
D) It is always directed.
References/ Articles/ Videos 12
Text books:
• Cormen, Leiserson, Rivest, Stein, “Introduction to Algorithms”, Prentice Hall
of India, 3rd edition 2012. problem, Graph coloring.
• Horowitz, Sahni and Rajasekaran, “Fundamentals of ComputerAlgorithms”,
University Press (India), 2nd edition
Websites:
1. geeksforgeeks.org/graph-data-structure-and-algorithms/
2. https://www.geeksforgeeks.org/difference-between-bfs-and-dfs/
Faculty-curated videos, NPTEL, 13
Coursera, LinkedIn, or other relevant
learning resources
1. https://onlinecourses.nptel.ac.in/noc23_cs96/preview
2. https://nptel.ac.in/courses/106106131
3. https://nptel.ac.in/courses/106106208
4. https://www.linkedin.com/learning/learning-algorithms
14
Class-Wise Feedback
15
Thank You
For queries
Email: [email protected]