0% found this document useful (0 votes)
9 views7 pages

Set D Answer Key

The document outlines a test for the course 'Design and Analysis of Algorithms' at SRM Institute of Science and Technology for the academic year 2024-2025. It includes multiple choice questions, problem-solving scenarios related to graph traversal, string hashing, and optimization problems, as well as vertex cover concepts. The test is structured into three parts with specific marks allocated for each section.

Uploaded by

shivjayabal1418
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)
9 views7 pages

Set D Answer Key

The document outlines a test for the course 'Design and Analysis of Algorithms' at SRM Institute of Science and Technology for the academic year 2024-2025. It includes multiple choice questions, problem-solving scenarios related to graph traversal, string hashing, and optimization problems, as well as vertex cover concepts. The test is structured into three parts with specific marks allocated for each section.

Uploaded by

shivjayabal1418
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/ 7

SRM Institute of Science and Technology

College of Engineering and Technology

School of Computing

SRM Nagar, Kattankulathur - 603203, Chenglpattu District, Tamilnadu

Academic Year 2024-2025(EVEN)

SET D

Test: FJ III Date: 30-04-2025

Course Code & Title: 21CSC204J & Design and Analysis of Algorithms Duration: 1 hour 40 minutes

Year & Sem: II Year / IV Sem Maximum Marks: 50

Part A (Multiple Choice Questions) 8*1=8 marks

1) (c) 5
2) (b) T has n/2 edges
3) (c) 5
4) (b) 2
5) (a) O(N!)
6) (c) Both BFS and DFS
7) (a) 12
8) (c) 3
PART B: Answer all questions. 3*5 = 15 marks

9) Imagine you are a puzzle enthusiast who loves solving word puzzles. You have two sets of
word tiles X and Y , each containing a sequence of letters arranged in a particular order, say
X = ACB#BAB and Y = BCCACAB, here # is an unknown character which can be A or B or C.
Your task is to find the value of # so that the length of the longest common subsequence is
3. Justify your choice of #.
The LCS for the above is 4. So there is no choice of # that will give the LCS as 3.

10) There is a maze to be travelled by a mouse to find its cheese. The mouse decide to follow an
arbitary path as far as it can go. If the mouse hits on a dead end (where it cannot move further),
then the mouse will take a detour and follow another path and keep repeating this until it finds its
cheese. If the junctions on the maze are represented as nodes and the various roads emerging from
the junction are represented as edges, then what kind of graph traversal would match the mouse’s
strategy to find the cheese. Apply your claimed traversal on the following graph representation of a
maze to help the mouse (at node 1) search for its cheese
The mouse's behavior is:
 Follow a path as far as possible.
 If it hits a dead end, backtrack and try a new path.

This matches exactly the strategy of Depth First Search (DFS) traversal. (1 Mark)
Now, applying DFS starting from node 1 on the given graph:

DFS Traversal order: (3 Marks)


Can perform steps for DFS
Show a dead end
Backtrack and continue to traverse the remaining

Note : Any sequence of DFS can be followed


Final DFS traversal sequence:
Multiple answers are there for DFS so any sequence of DFS (1 Mark)

11.Given:
 Pattern P=132P = 132P=132
 Text T=335013265342T = 335013265342T=335013265342
 Hash function:
h(S)=(sum of digits of S)mod
 Process all substrings of length 3
T=335013265342
Substrings of length 3:
1. 335 → (3+3+5)=11 → 11 mod 5 = 1
2. 350 → (3+5+0)=8 → 8 mod 5 = 3
3. 501 → (5+0+1)=6 → 6 mod 5 = 1
4. 013 → (0+1+3)=4 → 4 mod 5 = 4
5. 132 → (1+3+2)=6 → 6 mod 5 = 1
6. 326 → (3+2+6)=11 → 11 mod 5 = 1
7. 265 → (2+6+5)=13 → 13 mod 5 = 3
8. 653 → (6+5+3)=14 → 14 mod 5 = 4
9. 534 → (5+3+4)=12 → 12 mod 5 = 2
10. 342 → (3+4+2)=9 → 9 mod 5 = 4

Substrings whose hash value is 1:


 335 (hash = 1)
 501 (hash = 1)
 132 (hash = 1)
 326 (hash = 1)
Thus, 4 substrings have the same hash value as the pattern PPP.
"132" is present in text T

PART C: Answer all questions. 3*9 = 27 marks


12. (a) A company is optimizing its production process and needs to determine the best
combination of components to include in a product, considering to maximize their total
effective value. The list of components along with their respective weights and effective
value is given in the below table. Find the optimal combination of components to be
included into the product which has a maximum capacity of 10kgs, ensuring maximum
performance value,
Due to technical difficulty, your manager decides to decrease the
capacity of the product from 10 kgs to 7 kgs. Without redoing the calculations, can you decide what
components will be carried in the 7 kgs bag? (7+2 marks)

(OR)
12

i.

ii. 1.Create a leaf node for each unique character and build a min heap of all leaf nodes
2.Extract two nodes with the minimum frequency from the min heap.
3.Create a new internal node with a frequency equal to the sum of the two nodes
frequencies. Make the first extracted node as its left child and the other extracted
node as its right child. Add this node to the min heap.
4.Repeat steps#2 and #3 until the heap contains only one node. The remaining
node is the root node and the tree is complete.
iii.

iv.

13
(OR)

Solution:
14 .a)
(a) Define minimum vertex cover of a graph. (2 marks)
(b) Provide a polynomial-time approximation algorithm A to find a vertex cover (VC) of a graph. (3
marks)
(c) Using the above claimed algorithm A, find a vertex cover (say S) of the following graph starting
from the edge (M, R). (2 marks)
(d) Is the above vertex cover S a minimum vertex cover? If not, provide a minimum vertex cover of
the graph. (2 marks)

Solution:
a) A minimum vertex cover in a graph is a set of vertices that includes at least one endpoint of every
edge in the graph, and the set has the smallest possible size. In other words, it's the smallest group
of vertices that "covers" all the edges.
b)
c) S= {M,R,N,Q,O,P}
d) S is not minimum vertex Cover.
Minimum vertex cover Vc={M,N,O}
(OR)

Solution
i)
Statement A: True
Statement B: Unknown
Statement C: True
Statement D: False
ii)

 iii) Yes, it is in NP.


 Reason:
o A Hamiltonian cycle (a cycle visiting each vertex exactly once) can be
guessed and verified in polynomial time.
o Given a proposed path, we can easily check in polynomial time:
 Whether it visits each vertex exactly once.
 Whether all edges exist.

Thus, the Hamiltonian Cycle problem is in NP.

You might also like