Dsa - QB - Unit Iv
Dsa - QB - Unit Iv
1. What is a graph? K1
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.
4. Find out the in-degree and out-degree of each node in the given graph K1
A cyclic graph is a directed graph which contains a cycle ( a path from at least one
node back to itself).
An acyclic graph is a directed graph which contains absolutely no cycle, that is no
node can be traversed back to itself.
Prim's Algorithm is a greedy algorithm that is used to find the minimum spanning tree
from a graph. Prim's algorithm finds the subset of edges that includes every vertex of
the graph such that the sum of the weights of the edges can be minimized.
18. Mention the procedure to find minimum spanning tree using Kruskal’s K1
Algorithm.
o First, sort all the edges from low weight to high.
o Now, take the edge with the lowest weight and add it to the spanning tree. If the
edge to be added creates a cycle, then reject the edge.
o Continue to add the edges until we reach all vertices, and a minimum spanning
tree is created.
1. Data Structure uses Queue data structure for uses Stack data
finding the shortest path. structure.
Step 2: Select a starting node (visiting a node) and insert it into the Queue.
Step 3: Provided that the Queue is not empty, extract the node from the Queue and
insert its child nodes (exploring a node) into the Queue.
5 Show how Prims algorithm and Kruskals algorithm are used to find the minimum
spanning tree for the given graph. (16)
6 Apply appropriate algorithm to find the shortest path from ‘A’ to every other node of
A.For the given graph (16)