0% found this document useful (0 votes)
55 views5 pages

CT2 - D - Answer Key

The document appears to be a test for a course on design and analysis of algorithms. It contains 15 multiple choice and written response questions covering topics like binary search, divide and conquer algorithms, dynamic programming, greedy algorithms, Huffman coding, longest common subsequence, master's theorem, minimum spanning trees, 0-1 knapsack problem, and optimal binary search trees. Students are asked to determine time complexities, solve recurrences using the master's theorem, develop divide and conquer algorithms, solve problems like knapsack and longest common subsequence using dynamic programming, and construct optimal binary search trees.
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)
55 views5 pages

CT2 - D - Answer Key

The document appears to be a test for a course on design and analysis of algorithms. It contains 15 multiple choice and written response questions covering topics like binary search, divide and conquer algorithms, dynamic programming, greedy algorithms, Huffman coding, longest common subsequence, master's theorem, minimum spanning trees, 0-1 knapsack problem, and optimal binary search trees. Students are asked to determine time complexities, solve recurrences using the master's theorem, develop divide and conquer algorithms, solve problems like knapsack and longest common subsequence using dynamic programming, and construct optimal binary search trees.
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/ 5

SRM Institute of Science and Technology Set A

College of Engineering and Technology


School of Computing
SRM Nagar, Kattankulathur – 603203, Chengalpattu District, Tamilnadu
Academic Year: 2021-22 (Even)

Test: CLA-T2 Date: 27-05-2022


Course Code & Title: 18CSC204J Design and Analysis of Algorithms Duration: 100 min
Year & Sem: II Year / IV Sem Max. Marks: 50

Q. Part A
No
1 The best-case and worst-case complexities of Binary Search are
a) O(1) and O(log n)
b) O(1) and O(n)
c) O(log n) and O(log n)
d) Both best and worst case is O(log n)
2 Algorithm A1 can compute min-max in a1 comparison without divide and conquer. Algorithm
A2 can compute min-max in a2 comparison with divide and conquer. What could be the
relation between al and a2 considering the worst-case scenarios?
a) a1 < a2
b) a1 > a2
c) a1 = a2
d) Depends on the input
3 Time complexity of Strassen’s matrix multiplication problem is:

a)

b)

c)

d)
4 Find the Euclidean distance between the po
ints (4,3) and (7,5)
a) √3
b) √13
c) √19
d) √5
5 Which algorithm strategy builds up a solution by choosing the option that looks the best at
every step.
a) greedy method
b) branch and bound
c) dynamic programming
d) divide and conquer
6 The total running time of fractional Knapsack problem using simple approach.
a) O(n)
b) O(log n)
c) O(2n log n)
d) O(2n)
7 Suppose the letters a, b, c, d, e has the probabilities 0.3, 0.3, 0.2, 0.1, 0.1, which of the
following is the Huffman code for the above letters?
a) 100, 110, 00, 10, 01
b) 10, 11, 00, 010, 011
c) 100, 110, 11, 10, 11
d) 10, 111, 00, 01, 01
8 Dynamic programming is characterized by
(1) Distinct sub-problems
(2) Overlapping sub-problems
(3) Optimal substructures
(4) Sub-optimal or near optimal substructures
a) 1 and 3
b) 2 and 3
c) 1 and 4
d) 2 and 4
9 Time complexity of Longest common subsequence using dynamic programming is
a) O(m!)
b) O(mn)
c) O(n!)
d) O(n)
10 Let X = ABRACADABRAAB and Y = YABBADABBADOO. The Longest Common Subsequence, Z,
of X and Y is
a) Z = DAB
b) Z = AAB
c) Z = ABADABA
d) Z = ABADABAAB
Part B

11 What is Master theorem to solve recurrence relations and solve the below relations using
master method.
a) 𝑇(𝑛) = 2𝑇 (𝑛) + √𝑛
4
b) 𝑇(𝑛) = 7𝑇 (𝑛) + 𝑛2
2

Solution:
a)

b)
12 Develop a straightforward and recursive algorithm using divide and conquer to find a
maximum and minimum number in a set of n elements. Explain with an example.

Solution:
Straightforward Method:

Divide and conquer method:

Compared to Naïve method, in divide and conquer approach, the number of comparisons is
less.
Examples to be given.
13 Determine the minimum cost spanning tree using Kruskal’s method.

Solution:
Cost = 37

14 Explain 0/1 Knapsack problem. Solve the following problem using Dynamic programming.
Max weight = 7, (P1, P2, P3, P4) = (1, 4, 5, 7) and (W1, W2, W3, W4) = (1, 3, 4, 5).

Solution:

Items: {I1, I2, I3, I4} = {0, 1, 1, 0}

15 Construct an Optimal Binary Search Tree for the given values:


Key A B C D

Probability 0.1 0.2 0.4 0.3

Solution:
Example computations of C[1,2], C[1,3], C[1,4] to be given.
E.g.:

Optimal Binary Search Tree:

You might also like