Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Code No.: CS211/13CS209 II B.Tech. II Sem. (RA13/RA11) Supplementary Examinations, March/April - 2019 Design & Analysis of Algorithms

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

Code No.

: CS211/13CS209
II B.Tech. II Sem. (RA13/RA11) Supplementary Examinations, March/April - 2019
DESIGN & ANALYSIS OF ALGORITHMS
(CSE)
Time: 3 Hours Max. Marks: 70
PART – A
Answer ALL questions
All questions carry equal marks
10 x 2
1. Consider brute force algorithm for adding two n × n matrices. What is its basic operation?
How many times is it performed as a function of the matrix order n? As a function of the
total number of elements in the input matrices?
2. What is the average number of comparisons required to search a key element in linear
search?
3. What is the solution of the recurrence relation T(n)=2T(n/4)+n 1/2 with T(1) = 1?
4. For merging two unsorted list of size p and q into sorted list of size (p + q) what is the time
complexity in terms of number of comparisons?
5. What is the recurrence relation that captures the running time of the Tower of Hanoi
problem with n discs? What is its solution?
6. What is the time-complexity of the Kruskal’s algorithm for finding a minimum spanning tree
of a weighted graph G with n vertices and m edges?
7. Can Dijkstra’s single source shortest path algorithm be applied for a graph instance with
negative edges? Justify.
8. An array of n distinct elements is said to be un-sorted if for every index i such that 2 ≤ i ≤ n −
1, either A[i] > max{A[i − 1], A[i + 1]}, or A[i] < min{A[i − 1], A[i + 1]}. What is the time-
complexity of the fastest algorithm that takes as input a sorted array A with n distinct
elements, and un-sorts A?
9. What is the difference between Branch and Bound, and Backtracking techniques?
10. Describe the Brute force algorithm for Subset-sum problem. What is its complexity?
PART – B
Answer any FIVE questions
All questions carry equal marks
5 x 10
1. a) You have n > 2 identical-looking coins and a two-pan balance scale with no weights. One of
the coins is a fake, but you do not know whether it is lighter or heavier than the genuine
coins, which all weigh the same. Design a Θ(1) algorithm to determine whether the fake coin
is lighter or heavier than the others.
b) Design a recursive algorithm for computing 2 n for any nonnegative integer n that is based
on the formula 2n = 2n−1 + 2n−1. Set up a recurrence relation for the number of additions made
by the algorithm and solve it. Is it a good algorithm for solving this problem?
2. a) Consider the modified binary search algorithm where it splits the input not into two sets
of almost –equal sizes, but into three sets of sizes approximately one-third. Write the
recurrence for this ternary search algorithm and find the asymptotic complexity of this
algorithm.
b) Write Kruskals algorithm to find minimum spanning tree? Explain with an example.

[P.T.O]
3. a) Given an unsorted collection of elements, design an efficient algorithm to sort them in
either ascending or descending order. Analyse the complexity of the algorithm. [8]
b) Among the Mergesort and Quicksort, which sorting algorithm you prefer. Justify your
answer. [2]
4. Give the necessary recurrence relation used to solve 0/1 knapsack problem using dynamic
programming. Apply it to solve the following instance and show the results n=4, m=5
(Capacity), values 12,10,20,15 and weights are 2,1,3,2 respectively.
5. Design an algorithm for finding an optimal binary search tree using dynamic programming
strategy. What is the complexity of the algorithm?
6. a) Apply the branch-and-bound algorithm to solve the traveling salesman problem for the
following graph: [6]

b) Define n-Queens problem. Give the state space tree for solving 4-Queens problem for at
least one solution. [4]
7. a) Write a Backtracking algorithm for the Hamiltonian circuit problem.
b) Apply backtracking to solve the following instance of the subset sum problem:
A = {1, 3, 4, 5} and d = 11.
8. a) When a problem can be said to be NP-Complete problem?
b) Knapsack problem is: given n items of known weights wi and values vi, i = 1, 2, . . . , n, and
a knapsack of capacity W, find the most valuable subset of the items that fit in the knapsack.
Describe how to apply branch and bound technique to solve the knapsack problem.

*

You might also like