Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Reg. No.

:
Name :

Mid-Term Examinations – Nov 2021


Programme B. Tech Semester Fall 2021-22
Course Design Analysis Of Algorithm Code CSE3004
Faculty Slot/ Class
Dr. Shweta Saxena E11+E12+E13/0299
No.
Time 1 ½ hours Max. Marks 50

Answer all the Questions

Mark
Q.No. Question Description
s

1 Consider the following problem statement:


Given a list of cities and the distances between each pair of cities, what is the shortest
possible route that visits each city exactly once and returns to the origin city?
(i) How will you solve this problem and decide its class (P, NP, or NP complete). 10
(ii) Draw a pictorial set representation of P, NP, or NP complete problems to
justify the answer. Also explain the terms used in your diagram.
2 Consider the following list of items:
Item no. Weights Profits
1 8 32
2 6 18
3 15 30
10
4 4 4
A shopkeeper has a knapsack of 30 kg. He wants to fill the item such that after selling
each item from the knapsack he get the maximum profit. Write an algorithm to solve this
problem in O (n) time. What will be the time complexity when the above items are not
arranged in the order they are given?
3 Suppose there are 2 villages near to the city “Bhopal”. A salesman has to start his journey
from Bhopal and visit all these villages. Finally, he has to come back to the “Bhopal
headquarter”. The constraint is that he can’t backtrack the path and he can’t revisit any
village during the path. Can you solve this problem using the greedy approach? If your 10
answer is Yes, solve this problem using the greedy approach. If your answer is no, what
will be the appropriate approach to solve this problem? Justify your answer by taking an
example graph.
4 Consider the 7 files, each having the following no. of records in it: 4,1,9,3,13,18,15. How
you will calculate the minimum cost of merging these records using the greedy approach.
10
Design the objective function for this problem. How much time is required to solve your
problem?
5 Consider a string of length l of distinct symbols. How many non-null proper substrings
are possible? Match the pattern string “ababd” in text string “ababcabcabcabababd” using 10
KMP algorithm.

Page 1 of 2
Page 2 of 2

You might also like