Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

GroupAssignmentQuestions - Sec E

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

AMRITA VISHWA VIDYAPEETHAM

AMRITA SCHOOL OF ENGINEERING


DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
19CSE302 - Design and Analysis of Algorithms
Group Assignment
Assignment posted on: 27. 08. 2021 Submission date: 27. 08. 2021
Time : 2 hr 00 mins
Course Outcomes
CO1: Evaluate the correctness and analyze complexity of algorithms.
CO2: Understand and implement various algorithmic design techniques and solve
classical problems
CO3: Design solutions for real world problems by identifying, applying and
implementing appropriate design techniques.
CO4: Design solutions for real world problem by mapping to classical problems
CO5: Analyze the impact of various implementation choices on the algorithm
complexity

Question 1: (Fig: 1)How long will it take to complete UG programme? Every UG


student has to complete the set of courses in the curriculum to finish their
programme successfully. If you are given a chance to do as many courses as possible
in a semester with a constraint: some courses has a pre-requisite course, which has
to be completed in the previous semesters, what is the minimum number of
semesters to complete all the courses?(CO4)

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

Question 3: (Fig: 3) Consider the following communication network where each


node represents router. A network designer is trying to find single point of failure in
the following design and because of which network gets disconnected. Identify all
such routers that causes single point of failure and sub networks generated because
of these routers(CO2)

Fig: 3

Question 4: (Fig: 4) A water distributing company have intermediate tanks/


reservoirs located at different cities, represented as graph. Each vertex represents a
tank and each edge a represents a pipeline connection(where edge weight value is
flow rate/sec in litres) between tanks. The wires are weighted by the maximum flow
rate they can support. The company comes to you and asks you to develop an
algorithm to find the path with maximum flow rate from a source s to a destination t.
As you would expect, the flow rate of a path is the minimum of the flow rate of the
edges on that path—the minimum edge is the bottleneck. Please ignore numbers
given in brackets near vertices. [Hint: Modify the single source shortest path
Algorithm](CO3)

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 6: Explain what adjustment if any need to be made in Dijkstra’s and/or in


an underlying graph to solve the following problems.
a)  Solve the Single source shortest paths problem for directed weighted
graphs.
b)  Find a shortest path between two given vertices of weighted graph or
digraph.
c)  Find the shortest paths to a given vertex from each other vertex of a
weighted graph
Does there exist some connected undirected graph G with positive edge weights w
such that G has a shortest path tree S and a minimum spanning tree T that do not
share any edges? Prove your answer.

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.

(b) Justify the time complexity for the proposed solution.

(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

Where T, I and F are the parameters

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.

b. Justify the complexity also

c. Implement it and present output on two graphs.

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.

(a) Propose a pseudocode for the problem above.

(b) Analyze and Justify its complexity

(c) Implement the same with two sample maps / graphs.

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.

You might also like