Thapar Institute of Engineering and Technology, Patiala: Any, Suitably
Thapar Institute of Engineering and Technology, Patiala: Any, Suitably
Note: Attempt subparts of a question in sequence at one place. Assume missing data, if
any, suitably.
Q1. Execute Ford Fulkerson Algorithm to find the maximum flow for a graph (Fig. 1). (7)
Show all the intermediate stages of residual graph. What is the minimum cut
corresponding to the obtained maximum flow? If each edge capacity in the graph
(shown in Fig. 1) is increased by a value 1, then what will be the changed
maximum flow?
5
10
10
Fig. 1
Q2. (a) State the differences between the 2-approximation and 3/2-approximation (1)
algorithms for the traveling-salesman problem with the triangle inequality.
(b) Solve the following instance of the knapsack problem using the branch-and- (6)
bound technique. Draw the state-space tree which is generated while using
the branch-and-bound technique.
Item Weight Value
1 6 72
2 7 63 Knapsack Capacity W = 12.
3 5 40
4 4 12
Q3. Apply dynamic programming approach to determine the cost and structure of all (7)
the possible optimal binary search trees for a set of n = 3 keys with the following
probabilities:
0 1 2 3
p, 4/17 1/17 4/17
q, 3/17 1/17 1/17 3/17
1/2
Q4. Instructor wants to schedule some final exams for CS courses with the following (7)
course numbers: C101, C112, C213, C224, C315, C326, C417, C428, and C439.
Suppose that there is no student in common taking the following pairs of courses:
How many minimum exam slots are necessary to schedule exams? Give
appropriate algorithm and show all intermediate steps involved by using that
algorithm.
Q5. Write an efficient algorithm or pseudocode to compute the shift value using good (7)
suffix shift rule in the Boyer Moore string matching algorithm. It should include
the required pre-processing logic along with the update in the shift value. Explain
the proposed algorithm or pseudocode for the pattern "CTTACTTAC".
Note: The proposed algorithm or pseudocode can only take the pattern as an
input argument. If needed then length of the pattern can also be considered as an
input argument.
2/2
Roll No. Name: Group:
TIET Patiaia
Department of Computer Science & Engineering
UCS415: Design and Analysis of Algorithms
/Vote: All answers must be written within the space provided for each question. Overwritten
answers vvill not be evaluated. Use only capital alphabets (A/B/C/D) to record your responses.
Q5. Which one of the following does not provide an optimal solution for 8-queens problem?
A. 5,3,8,4,7,1,6,2 B. 4,1,5,8,6,3,7,2 C. 1,6,3,8,3,2,4,7 D. 6,2,7,1,4,8,5,3
Q6. For the given instance of 0/1 knapsack problem: Weight = [4,7,5,3], Value = [40,42,25,12] and
Knapsack Capacity = 10, what would be the upper bound cost at the root of state space tree?
Q7. The search cost for the binary search tree shown here with the
following successful and unsuccessful search probabilities is
0 1 2 3 4
pi 3 3 1 1
qi 2 3 1 1 1