School of Computer Science Engineering and Technology
Course-B.Tech Type- Core
Course Code- CSET206 Course Name- DAA (Tutorial-10)
Year- 2024 Semester- EVEN
Date- 20/03/2024 Batch- 2022-2026
CO-Mapping
CO1 CO2 CO3
Q1 √
Q2 √
Q3 √
Objectives
1. Students will be able to learn how to find the topological sorting of a
graph.
2. Students will be able to learn how to apply DFS to get the number of
connected components in a graph.
3. Students will be able to learn how to apply DFS to find the articulation
points in a graph (Tarjan’s Algorithm).
Q1. Consider the following directed graph
School of Computer Science Engineering and Technology
Find the topological sorting of the given graph.
Solution:
Steps to Find Topological Sorting
1. Apply DFS to get the finishing time for all the vertices.
2. List the vertices in decreasing order of their finishing time.
One of the topological sortings of the above graph is as follows:
A, C, D, B, E, H, F, G.
Q2. Consider the following graph
School of Computer Science Engineering and Technology
Find the number of connected components using DFS.
Solution:
The algorithm to compute the number of connected components is as
follows:
Apply the above Algorithm to the given graph
Total number of connected components = 3 [{v1, v2, v3, v4, v5, v6}, {v7,
v8, v9}, {v10, v11, v12}]
Q3. Find the articulation points in the given graph using Tarjan’s Algorithm
Solution:
Steps of Tarjan’s Algorithm to find articulation points:
[Step 1.] Find the depth-first spanning tree T for G
[Step 2.] Add back edges in T
School of Computer Science Engineering and Technology
[Step 3.] Determine DNF(i) and L(i)
✓ DNF(i): the visiting sequence of vertices i by depth-first search
✓ L(i): the least DFN reachable from i through a path consisting of
zero or more tree edges followed by zero or one back edge
[Step 4.] Vertex i is an articulation point of G if and only if either:
✓ i is the root of T and has at least two children
✓ i is not the root and has a child j for which L(j)>=DFN(i)
Articulation points: A, H, G, J