0% found this document useful (0 votes)
22 views2 pages

AADS Sample Endterm

Uploaded by

cse24013
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views2 pages

AADS Sample Endterm

Uploaded by

cse24013
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

TEZPUR UNIVERSITY

Spring semester End Term Exam, 2020


Design and Algorithms (CO 206)

Maximum Marks : 60 Duration : 3 hrs


You may answer as many questions as you like but maximum you get is 60.

1. Following is a version of cycle finding problem.

Input: Undirected graph G = (V, E), and an integer k.


Output (yes/no:) Does G have a cycle of length k?

Does the above problem belong to the class NP? [7]

2. Answer True / False and provide a counterexample or a short justification. Correct answers with incorrect
justification will get only half of the marks. [6×5]
n+1 n
a) 32 ∈ Θ(32 ).
b) An optimal solution to a 0/1 knapsack problem will always contain the object with the greatest
benefit/weight ratio.
c) Dijkstra’s algorithm can find the longest path in a graph (with positive weights) from a source vertex
if we multiply every edge weight with −1.
d) If T (1) = 1 and T (n) = T (n/5) + T (4n/5) + n , then T (n) ∈ Θ(n).
e) ) If the weights of the edges in a connected graph are NOT all distinct, there is more than one
minimum spanning tree.
f) Consider three problems X, Y and Z. If X <p Y and Y <p Z and Y is NP-complete problem, then
Z is also NP-complete.

3. Consider the following undirected graph with weighted edges.

a) What will be the minimum spanning tree of the graph below? How many MSTs does the following
graph have? [4+3]
b) Run Dijkstra’s algorithm on the graph below considering D as the source vertex. Show the status of
the distance array at each iteration. [10]
c) Execute the Bellman-Ford algorithm for the graph below for finding the length of the shortest paths
from D to the remaining vertices. Show the table values at each iteration. [10]

1 2
−8

A 8 -8
C F

1 −3
2 2

B E
2
4. Consider the table below to find the minimum number of multiplications required to multiply 5 matrices
M1 , M2 , M3 , M4 , M5 . I have filled up some cells for you to start with. Fill up the remaining cells to get
the final value M M [1, 5] using DP solution discussed in the class. [15]

MM 1 2 3 4 5

1 0 21

2 0 28

3 0 44

4 0 132

5 0

5. Each week, you can either attend your classes ONLINE (ON) or physically attend CLASSROOM (CR) at
CSE Dept. In week i, if you attend classes in online mode you will spent ONi hours else you will have to
spend CRi hours if you attend the classes offline in the dept. However if you are attending classes online
in week i and switch to offline mode in week i + 1 or vice-versa, you have to spent extra S hours to switch
from online to offline; because you have to go to HoD, Dean and CoE to apply for change of mode request.
The time required for switching is fixed, i.e, S hours.
Our task is to prepare a plan for attending classes over a period of n weeks, each week we will attend
classes in either online (ON) mode or offline (CR) mode. The total credit hours of a plan is the sum of
the time we spent for each of the n months, plus S hours switching time for each time you switch modes
of attending classes. The plan can begin in either modes.
Given the value of switching time S, and sequence of values {ON1 , ON2 , . . . , ONn } and {CR1 , CR2 , . . . , CRn },
you have to find an optimal plan of minimum credit hours.

a) Prove by counter-example that the following greedy algorithm does not solve this problem. [5]
for i = 1 to n
if ONi < CRi
Output “Online in Month i”
else
Output “Offline in Month i”
end

For your counter-example, state the correct answer and also the output of the above algorithm.
b) Design an efficient algorithm that takes as input n, S and sequences{ON1 , ON2 , . . . , ONn } and
{CR1 , CR2 , . . . , CRn }, and returns the required credit hour of an optimal plan. Analyze the run-
time of your algorithm. [15]

You might also like