GroupAssignmentQuestions - Sec E
GroupAssignmentQuestions - Sec E
GroupAssignmentQuestions - Sec E
Fig:1
Question 2: (Fig: 2)
a. Prove that the “Every directed graph is a dag of its strongly connected
components.”Use the following graph and solve it to prove whether the statement
given is True or False.
b. Can we use SCC algorithm to check if the graph contains cycle or not before we
apply topological ordering algorithm to confirm whether the input to the topological
algorithm is a DAG or not. Comment on the time complexity analysis of this
approach(CO5)
Fig: 2
Fig: 3
Fig: 4
Question 5: (Fig: 5)
a. Run the Bellman-Ford shortest path algorithm on the following graph, starting
from vertex a. Specifically, fill in the tables below.
b. Suppose you are given a directed graph that has negative values on some of the
edges. The Bellman Ford algorithm will give the correct solution for shortest paths
from some starting vertex s, if there are no negative cycles. But suppose you don’t
know if the given graph has negative cycles. One way to check for negative cycles is to
run Bellman Ford for n iterations, instead of n-1. Explain. (CO1)
Fig: 5
Question 7:
Suppose we have a weighted directed acyclic graph with ‘N’ vertices and ‘M’ edges.
We need to compute the shortest path from a vertex ‘S to rest of the vertices. We
have seen that this can be done easily in O(N2) and O(N3) time.
But if a special ordering of the vertices and edges of the graphs is used the same can
be achieved in O(m+n) time.
(a)Propose the pseudocode for calculating the shortest path from vertex ‘S’ to all
other vertices.
(c) Implement the pseudocode as well and give output for atleast two graphs.
Question 8: Suppose a new broadband company has been set up in your city. The
broadband connections have to be laid down in the city from the company centre in
such a way that all major areas must be covered with minimal wiring required to
avoid extra cost. These major areas are connected to one another through one or
multiple paths.
Propose a pseudocode to solve the above problem and compute the minimum cost
also.
Implement the same with minimum two inputs. Analyze the time complexity
NOTE: Distance (in Kms) can be taken as weights of edges and can be considered
analogous to cost.
Question 9: (Fig: 6)For the given graph of the city where A, B, C and D represent
the major areas and the red colored lines represent the bridges over the canals. Is it
possible to have a tour of the major areas (with same source and destination ) by
covering each and every bridge exactly once. Say we start at A and come back to A at
the end by covering each bridge exactly once.
Propose a pseudo code that returns such tour (a path containing vertices and edges)
if it exists otherwise a ‘FALSE’.
Implement the same and provide output for two graphs given above.
[NOTE: Nodes can be repeated in the tour but each bridge will be covered exactly
once.)
Fig:6
Question 10: (Fig: 7)In real-world scenarios cost of performing different operations
is based on multiple parameters. Usually the data given for these parameters is
imprecise and non deterministic. Hence, while computing the minimum costs we
have to consider all these parameters with some optimization.
For such problems Dijkstra’s algorithms can also be used where the selection of the
best candidate to be added to the shortest path depends upon the rank (smallest)
computed for it
Rank=(2+T-I-F) / 3
For the given graph compute the shortest path from vertex-1 based on above data
and rank measure In the graph the multi-parameter weight is given in form of (T, I,
F).
Fig: 7
Question 11: A firm establishes multiple business centres in the city and the
operators from each business centre have to frequently visit the other centres for
different trainings. Hence, the firm plans to schedule some buses for their movement
with the minimum fuel cost.
a. Propose a pseudo code to move from each business centre to every other business
centre with minimum cost. It should return the minimum costs along with the path
to be followed in O(n3) complexity.
Question 12: Suppose we are given the map of a city with some major areas as
nodes. In this map some roads / streets can be one-way also. We have check if there
is a shortest directed connectivity from each major area to every other major area.
The output should be in form a adjacency matrix where Cell(i,j)= 1 if there is a
directed connectivity from i to j otherwise it will represent a zero.
Question 13: We are given a map of the air connectivity in the form of an adjacency
matrix A. A cell value A[i.j] will be ‘1’ if the flight (or connected flights) are available)
from place ‘i’ to place ‘j’. The adjacency matrix contains data in the special order
where for each row all 1’s will be coming in the initial columns followed by zeros in
the remaining columns.
(a) Propose a pseudocode to find out the city that has flights (direct/ connected) to
maximum other cities. The pseudocode must work in linear time complexity.
(b) Implement the above pseudocode with atleast two input examples.