Question Paper Code : 70005
B.E./B.Tech. DEGREE EXAMINATIONS, NOVEMBER/DECEMBER 2022.
Third Semester
Artificial Intelligence and Data Science
AD 3351 — DESIGN AND ANALYSIS OF ALGORITHMS
(Common to : Computer Science and Business Systems)
(Regulations 2021)
Answer ALL questions.
PART A — (10 × 2 = 20 marks)
- 1.
What is empirical analysis of an algorithm?
- 2.
For the algorithm to compute then! indicate (a) the natural size metric for its inputs and (b) its basic operation.
- 3.
What is the asymptotic best-case and worst-case running time of selection sort?
- 4.
If there are other points of a given set on the straight line through Pi and Pj, which of all these points need to be preserved for further processing in a line segment of the convex hull's boundary?
- 5.
What is the principal difference between dynamic programming and divide - and - conquer techniques?
- 6.
Can we use Prim's algorithm to find a spanning tree of a connected graph with no weights on its edges?
- 7.
Define Marriage matching problem. And state what is called as stable or unstable in it?
- 8.
What are the requirements to represent the simplex method to a linear programming problem in the standard form?
- 9.
What are tractable and intractable problems?
- 10.
Explain How can you get the second solution from the first one by exploiting a symmetry of the board?
PART B — (5 × 13 = 65 marks)
- 11.(a)
Consider the following recursive algorithm. ALGORITHM Riddle (A[0..n-1]) //Input: An array A[0..n-1] of real numbers if n = 1 return A[0] else temp <- Riddle(A[0..n-2]) if temp <= A[n-1] return temp else return A[n-1]
- (i)What does this algorithm compute?
- (ii)Set up a recurrence relation for the algorithm's basic operation count and solve it.
- Or
- (b)
- (i)In Glove selection, There are 22 gloves in a drawer: 5 pairs of red gloves, 4 pairs of yellow, and 2 pairs of green. You select the gloves in the dark and can check them only after a selection has been made. What is the smallest number of gloves you need to select to have at least one matching pair in the best case? In the worst case?
- (ii)Missing socks Imagine that after washing 5 distinct pairs of socks, you discover that two socks are missing. Of course, you would like to have the largest number of complete pairs remaining. Thus, you are left with 4 complete pairs in the best-case scenario and with 3 complete pairs in the worst case. Assuming that the probability of disappearance for each of the 10 socks is the same, find the probability of the best-case scenario; the probability of the worst-case scenario; the number of pairs you should expect in the average case.
- 12.(a)
- (i)Write the DFS algorithm(5)
- (ii)Apply the DFS-based algorithm to solve the topological sorting problem for the following digraph: [Figure: digraph with vertices a to g and edges a->b, b->c, c->d, d->g, e->a, f->b, f->c, f->e, f->g, g->e](8)
- Or
- (b)
- (i)Solve the Quick sort recursive function. T(n) = T(k) + T (n - k - 1) + n - 1 to yield a non-recursive form when k = 1. Give an "O" estimate of this form. Assume that T(0) = T(1) = 0 and T(2) = 2. You may assume that n is even.(5)
- (ii)Give the result of partitioning the array with standard Quick sort partitioning (taking the N at the left as the partitioning element). NEWPARTITIONQUESTION(8)
- 13.(a)
Create
- (i)Huffman tree and the(5)
- (ii)Huffman code for the following String: Eerie eyes seen near lake.(8)
- Or
- (b)
- (i)Write the all pairs shortest path algorithm(5)
- (ii)Apply the above algorithm to solve the all-pairs shortest path problem for the digraph with the following weight matrix: [Matrix rows: 0 2 inf 1 8; 6 0 3 2 inf; inf inf 0 4 inf; inf inf 2 0 3; 3 inf inf inf 0](8)
- 14.(a)
Starting from the following flow (printed above or to the right of the capacities), perform one iteration of the Ford-Fulkerson algorithm. Choose a shortest augmenting path, i.e., the path with the fewest number of arcs. [Figure: flow network from a source s through vertices 2 to 7 to a sink t, each arc given as flow/capacity: s->2 10/10, s->3 2/3, s->4 13/15, 2->3 2/4, 2->5 7/9, 2->6 1/15, 3->4 1/4, 3->6 7/7, 4->7 14/30, 5->6 0/15, 5->t 7/10, 6->7 0/15, 6->t 8/9, 7->3 4/6, 7->t 10/10]
- (i)Write down your shortest augmenting path.(7)
- (ii)Perform the augmentation. What is the value of the resulting flow?(3)
- (iii)Is the resulting flow optimal? If so, give a min cut whose capacity is equal to the value of the flow. If not, give a shortest augmenting path.(3)
- Or
- (b)
Solve the following linear programming problems geometrically. maximize 3x + y subject to -x + y <= 1, 2x + y <= 4, x >= 0, y >= 0
- 15.(a)
Solve the following instance of the knapsack problem by the branch-and bound algorithm: [Table: item / weight / value: 1: 10, ₹100; 2: 7, ₹63; 3: 8, ₹56; 4: 4, ₹12; W = 16]
- Or
- (b)
Apply the nearest-neighbor algorithm to the instance defined by the intercity distance matrix below. Start the algorithm at the first city, assuming that the cities are numbered from 1 to 5 and Compute the accuracy ratio of this approximate solution. [Matrix rows: 0 14 4 10 inf; 14 0 5 8 7; 4 5 0 9 16; 10 8 9 0 32; inf 7 16 32 0]
PART C — (1 × 15 = 15 marks)
- 16.(a)
Suppose you are given an array A of size 'n' that either contains all zeros or 2n/3 zeros and n/3 ones in some arbitrary order. Your problem is to determine whether contains any ones?
- (i)Give an exact lower bound in terms of 'n' (not using asymptotic notation) on the worst-case running time of any deterministic algorithm that solves this problem.(2)
- (ii)Give a randomized algorithm that runs in O(1) time and gives the right answer with probability at least 1/3.(8)
- (iii)Give a randomized algorithm that runs in O(1) time and gives the right answer with probability at least 5/9.(5)
- Or
- (b)
- (i)Write a pseudocode for a divide-and-conquer algorithm for the exponentiation problem of computing a^n where a>0 and n is a positive integer, using recursion.(8)
- (ii)Set up and solve a recurrence relation for the number of multiplications made by this algorithm.(5)
- (iii)How does this algorithm compare with the brute-force algorithm for this problem?(2)