Question
Give an algorithm for topological sort. Obtain a topological ordering for the following graph:
Answer :
Word Count : 331
### Algorithm for Topological Sort (Kahn’s Algorithm) Input: A directed acyclic graph (DAG) with `n` vertices and `m` edges. Output: A topological ordering of the vertices. --- ### Steps: 1. Compute in-degree for each vertex: - Initialize an array `in_degree` of size `n` with all zeros. - For each edge `(u, v)`, increment `in_degree[v]` by 1. 2. Initialize a queue: - Enqueue all vertices with `in_degree = 0` (i.e., no incoming edges). 3. Topological Sort Process: - Initialize an empty list `topo_order` ___ ________ _______ _______ ______ ________ __________.
______ _______ _____ ______ ________ ____ _____ _____ __________ ______ _________.
__________ ______ ___ __________ ________ __________ ____ _____ ______ _______ ______.
____ ________ ________ ___ ____ ____ ________.
_________ _____ ________ _______ __________ _______ ___ ____ ____ _____ _____ _____.
________ _________ ___ _______ ______ _____ _____ ________ ____ ________.
_________ _____ _______ ____ __________ ______ _________ _____ ____.
____ _______ ___ _________ ________ _________ ______ ____ _________ _________ _________.
__________ _________ __________ ___ _____ ____ ______ _________ ___ ____ ____.
______ _________ ______ _____ ________ _________ __________.
______ ___ ___ _____ ___ _______ _________ _________ _________.
__________ _____ ___ _________ _______.
________ __________ ______ _______ ______ ___.
___ _____ _______ ________ ________.
_________ _________ _______ ____ ______ _________ _______ _________ ________ ___ __________ ______.
________ ______ ___ ______ ______.
________ ___ ___ __________ __________ _______ ________ __________.
_______ __________ _________ ______ _______ ___.
_______ _______ ___ ______ _____ _____ ____ ______.
___ ________ ____ ________ _____ ___ _______ ______ __________ __________.
_______ ____ ___ __________ __________ ___.
__________ __________ _____ _____ _______ _____ _______ __________ _____ _____ ___ _____.
___ _________ ______ ___ ________.
________ ________ _____ ____ ______ __________ ___.
________ _____ _______ ______ ___ ___ ________ ________ ________.
___ _____ ____ ________ _______ _____ __________ ____ ___.
____ ________ ____ __________ ____ __________ __________ ________ __________ __________ ______.
_____ ____ ____ _______ _______ _________.
__________ ___ ___ _____ _____ __________ ___.
__________ _________ __________ _______ ________ ________ __________.
Get Full Answer on WhatsApp
### Algorithm for Topological Sort (Kahn’s Algorithm) Input: A directed acyclic graph (DAG) with `n` vertices and `m` edges. Output: A topological ordering of the vertices. --- ### Steps: 1. Compute in-degree for each vertex: - Initialize an array `in_degree` of size `n` with all zeros. - For each edge `(u, v)`, increment `in_degree[v]` by 1. 2. Initialize a queue: - Enqueue all vertices with `in_degree = 0` (i.e., no incoming edges). 3. Topological Sort Process: - Initialize an empty list `topo_order` ___ ________ _______ _______ ______ ________ __________.
______ _______ _____ ______ ________ ____ _____ _____ __________ ______ _________.
__________ ______ ___ __________ ________ __________ ____ _____ ______ _______ ______.
____ ________ ________ ___ ____ ____ ________.
_________ _____ ________ _______ __________ _______ ___ ____ ____ _____ _____ _____.
________ _________ ___ _______ ______ _____ _____ ________ ____ ________.
_________ _____ _______ ____ __________ ______ _________ _____ ____.
____ _______ ___ _________ ________ _________ ______ ____ _________ _________ _________.
__________ _________ __________ ___ _____ ____ ______ _________ ___ ____ ____.
______ _________ ______ _____ ________ _________ __________.
______ ___ ___ _____ ___ _______ _________ _________ _________.
__________ _____ ___ _________ _______.
________ __________ ______ _______ ______ ___.
___ _____ _______ ________ ________.
_________ _________ _______ ____ ______ _________ _______ _________ ________ ___ __________ ______.
________ ______ ___ ______ ______.
________ ___ ___ __________ __________ _______ ________ __________.
_______ __________ _________ ______ _______ ___.
_______ _______ ___ ______ _____ _____ ____ ______.
___ ________ ____ ________ _____ ___ _______ ______ __________ __________.
_______ ____ ___ __________ __________ ___.
__________ __________ _____ _____ _______ _____ _______ __________ _____ _____ ___ _____.
___ _________ ______ ___ ________.
________ ________ _____ ____ ______ __________ ___.
________ _____ _______ ______ ___ ___ ________ ________ ________.
___ _____ ____ ________ _______ _____ __________ ____ ___.
____ ________ ____ __________ ____ __________ __________ ________ __________ __________ ______.
_____ ____ ____ _______ _______ _________.
__________ ___ ___ _____ _____ __________ ___.
__________ _________ __________ _______ ________ ________ __________.
Get Full Answer on WhatsApp
IGNOU NEWS
Assignment Submission Last Date Extended Till 30 June 2026 Click Here★★★IGNOU June 2026 TEE Date Sheet Released Click Here★★★