0% found this document useful (0 votes)
84 views

Design and Analysis of Algorithms Dec 2023

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
84 views

Design and Analysis of Algorithms Dec 2023

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Code No: R2031052 R20 SET - 1

III B. Tech I Semester Regular/Supplementary Examinations, December -2023


DESIGN AND ANALYSIS OF ALGORITHMS
(Common to CSE, IT)
Time: 3 hours Max. Marks: 70
Answer any FIVE Questions ONE Question from Each unit
All Questions Carry Equal Marks
*****
UNIT-I
1. a) Give the algorithm for matrix additions and determine the time complexity of [7M]
this algorithm by frequency-count method.
b) Write the algorithm to find a factorial of a given number. Derive its efficiency [7M]
(OR)
2. a) Explain the general plan for analyzing the efficiency of a recursive algorithm. [7M]
b) What is an algorithm? Write Towers of Hanoi algorithm. [7M]

es
UNIT-II
3. a) Write Divide-And-Conquer recursive Merge sort algorithm and derive thetime [5M]

at
complexity of this algorithm.
b) Write an algorithm for prim’s method and find the minimum cost spanning tree [9M]
for the following graph.
pd
U
st
Fa

(OR)
4. a) Perform binary search on list of elements to find the key element using divide [5M]
and conquer, and also estimate the time complexity.
tu

b) Find shortest path using dijkstra’s algorithm for following graph [9M]
Jn

UNIT-III
5. a) How the reliability of a system is determined using dynamic programming? [5M]
Explain.
b) Solve the following instance of 0/1 KNAPSACK problem using Dynamic [9M]
programming. n = 3, (W1,W2,W3) = (2,3,4), (P1,P2,P3) = (1,2,5), and m = 6.
(OR)
6. a) Construct optimal schedule for the following jobs n=8, [7M]
(p1,p2,p3,p4,p5,p6,p7,p8)=(40,100,50,30,4,7,12,11) and
(d1,d2,d3,d4,d5,d6,d7,d8)=(1,4,2,3,3,2,2,1)

1 of 2

|'''|'|'|''||'''||||
Code No: R2031052 R20 SET - 1

b) Calculate shortest distances using All pairs shortest path algorithm [7M]

UNIT-IV
7. a) Find the Hamiltonian cycle in the following graph [7M]

es
b) Use Backtracking technique, solve the following instance for the Subset sum [7M]
problem, s=(6,5,3,7) and d=15.

at
(OR)
8. a) Give the formulation of modified knapsack problem using branch and bound [7M]
pd
and find the optimal solution using Least Cost Branch and Bound (LCBB) with
n=4, m=15, (p1…p4) = (15,15,17,23), (w1…w4) = (3,5,6,9)
b) Write an algorithm for N-Queens problem using Backtracking. [7M]
U
UNIT-V
9. a) Explain the features of nondeterministic algorithms. [7M]
st

b) Briefly explain about NP-hard and NP-complete problems. [7M]


(OR)
Fa

10. a) Prove or disprove: If there exists a polynomial time algorithm to convert a [7M]
Boolean formula in CNF into an equivalent formula in DNF, then P=NP.
b) Explain the strategy to prove that a problem is NP hard. [7M]
tu
Jn

2 of 2

|'''|'|'|''||'''||||
Code No: R2031052
R2031011
R2031051 R20 SET - 2

III B. Tech I Semester Regular/Supplementary Examinations, December -2023


DESIGN AND ANALYSIS OF ALGORITHMS
(Common to CSE, IT)
Time: 3 hours Max. Marks: 70
Answer any FIVE Questions ONE Question from Each unit
All Questions Carry Equal Marks
*****
UNIT-I
1. a) What are the features of an efficient algorithm? Explain with an example. [7M]
b) Write an algorithm to find the maximum element in an array of n elements. [7M]
Give the mathematical analysis of this non recursive algorithm.
(OR)
2. a) Differentiate between probabilistic analysis and amortized analysis. [7M]
b) Apply the step Count method to find the time Complexity of the following [7M]

es
algorithm.
for(i=n ;i>=1; i-=k)
{

at
Print” Hello”;
}

3. a)
Note: here k is some constant
pd UNIT-II
What is Minimum cost spanning tree? Explain an algorithm for generating [7M]
U
minimum cost spanning tree and list some applications of it.
b) Write a greedy algorithm for sequencing unit time jobs with deadlines [7M]
andprofits.
st

(OR)
4. a) Consider the directed edge-weighted graph shown below [9M]
Fa
tu
Jn

Show the execution of Dijkstra’s shortest path algorithm for solving the Single
Source Shortest Path (SSSP) problem on this graph. Use the vertex S as the
source.
b) List out the advantages and disadvantages of divide and conquer approach. [5M]
UNIT-III
5. a) Write the algorithm to compute 0/1 Knapsack problem using dynamic [6M]
programming and explain it.
b) Write a function to compute lengths of shortest paths between all pairs of [8M]

0 6 13
nodes for the given adjacency matrix

8 0 4
5 ∞ 0
(OR)
6. a) Describe the Matrix multiplication chains problem. Apply the recursive [7M]
solution of dynamic programming to determine optimal sequence of pair wise
matrix multiplications
1 of 2

|'''|'|'|''||'''||||
Code No: R2031052 R20 SET - 2

b) Compare and contrast divide and conquer, greedy and dynamic programming [7M]
problem solving strategies.
UNIT-IV
7. a) What is sum-of-subsets problem? Write a recursive backtracking algorithm for [7M]
sum of subsets problem.
b) Explain briefly about N-Queens Problem. Construct state space tree for placing [7M]
4-Queen’s.
(OR)
8. a) Write the algorithm for general iterative backtracking method and explain [7M]
various factors that define the efficiency of backtracking.
b) Write an algorithm for finding all m-colorings of a graph. [7M]
UNIT-V
9. a) Describe Cook’s theorem. [7M]

es
b) Give the characteristics of NP-hard problems. [7M]
(OR)
10. a) Write and explain nondeterministic knapsack algorithm. [7M]

at
b) Differentiate between NP-Complete and NP-hard problems. [7M]

pd
U
st
Fa
tu
Jn

2 of 2

|'''|'|'|''||'''||||
Code No: R2031052
R2031011
R2031051 R20 SET - 3

III B. Tech I Semester Regular/Supplementary Examinations, December -2023


DESIGN AND ANALYSIS OF ALGORITHMS
(Common to CSE, IT)
Time: 3 hours Max. Marks: 70
Answer any FIVE Questions ONE Question from Each unit
All Questions Carry Equal Marks
*****
UNIT-I
1. a) What is the time complexity of following function fun ( )? Explain. [7M]
int fun (int n) {
for (inti = 1; i<=n; i++)
for (int j = 1; j < n; j +=i)

es
Sum = Sum + i*j;
return (Sum);
}

at
b) Write an algorithm for linear search and analyze the algorithm for its time [7M]
complexity.

2. a)
pd (OR)
Give the algorithm for matrix multiplication and find the time complexity of
the algorithm using step-count method.
[7M]
U
b) What are the different mathematical notations used for algorithm analysis. [7M]
Discuss the Amortized analysis with an example.
UNIT-II
st

3. a) Derive the Best, Worst and Average time complexities of Quick sorting [10M]
technique. Show the result of running Quick sorting technique on the sequence
Fa

38,27,43,3,9,65,12,82, 10,56.
b) Write the control abstraction for divide and conquer technique. [4M]
(OR)
tu

4. a) Construct Minimum cost spanning tree using Prim’s algorithm. [9M]


Jn

b) Write the control abstraction for divide and conquer technique [5M]
UNIT-III
5. Using algorithm OBST compute W (i, j), R (i, j) and C (i, j), 0<=I < j <=4 for [14M]
the identifier Set (a1,a22,a3,a4)= (end, goto, print, stop) with
P(1)=1/20,P(2)=1/5, P(3)=1/10, P(4)=1/20,
Q(0)=1/5,Q(1)=1/10,Q(2)=1/5,Q(2)=1/20,Q(4)=1/20. Using the R (i, i) s
construct the optimal binary search tree
(OR)
6. a) Explain the Travelling Sales person problems with an example and analyze its [7M]
recurrence relation
1 of 2

|'''|'|'|''||'''||||
Code No: R2031052 R20 SET - 3

b) Find all pairs shortest paths for the following graph and write the algorithm. [7M]

UNIT-IV
7. a) If the portion of solution space for an 8-queens problem is given as (7, 1, 4, 6), [7M]
then identify the remaining portion of solution space. Use back tracking to
solve the problem.
b) Solve the given instance of sum of subset problem s={3,5,6,7} and d=15. [7M]
Construct a state space tree

es
(OR)
8. a) Consider the sum of subset problem n=4, sum=13, and w1=3, w2=4, w3=5 and [7M]
w4=6. Solve the problem using backtracking.

at
b) Solve the following instance of travelling sales person problem using Least [7M]
Cost Branch Bound.
pd
U
st
Fa
tu

UNIT-V
Jn

9. a) Explain in detail about P, NP and NP-complete classes. [7M]


b) List the characteristics of NP-hard problems. [7M]
(OR)
10. a) What are deterministic and non-deterministic algorithms? Distinguish between [7M]
them.
b) Explain how NP-hard and NP class problems are related with examples [7M]

2 of 2

|'''|'|'|''||'''||||
Code No: R2031051
R2031011
R2031052 R20 SET - 4

III B. Tech I Semester Regular/Supplementary Examinations, December -2023


DESIGN AND ANALYSIS OF ALGORITHMS
(Common to CSE, IT)
Time: 3 hours Max. Marks: 70
Answer any FIVE Questions ONE Question from Each unit
All Questions Carry Equal Marks
*****
UNIT-I
1. a) What are the Asymptotic notations? Explain and give its properties. [7M]
b) Explain the process of designing an algorithm. Give characteristics of an [7M]
algorithm.
(OR)
2. a) Discuss the Pseudo code conventions for expressing algorithms. [7M]
b) Define Theta notation. Explain the terms involved in it. Give an example. [7M]

es
UNIT-II
3. a) Find the minimum and maximum values for the list of elements 23, [7M]
45,32,78,54,12,39,86,77,21 using divide and conquer method.

at
b) Explain the working principle of Kruskal's algorithm. [7M]
(OR)
4. pd
a) Consider the array of elements and search the element 55 using binary search
25,35,45,55,65,66,67,75,76,77,78,86,87. Derive the time complexity of binary
[8M]

search.
U
b) Discuss Strassen's matrix multiplication with an example and derive its time [6M]
complexity.
st

UNIT-III
5. Compute OBST w(i,j), r(i,j), c(i,j), 0<=i<=j<=4 for set(a1,a2,a3,a4)=(for, if, else, [14M]
Fa

while) with p1=1, p2=4, p3=2, p4=1, qo=4, q1=2, q2=4, q3=1, q4=1 Using r(i,j)
construct OBST.
(OR)
6. a) Find the shortest tour of Traveling sales person for the following cost matrix [7M]
tu

∞ 12 5 7
using Dynamic Programming.

11 ∞ 13 6

Jn

4 9 ∞ 18
10 3 2 ∞
b) Explain Principle of optimality in Dynamic Programming with suitable example. [7M]
UNIT-IV
7. a) What is travelling salesman problem? Solve the following salesman problem [7M]

0 10 15 20
instance using Branch and Bound.

5 0 9 10

6 13 0 12
8 8 0 0
b) Explain the solution to the graph coloring problem using backtracking. [7M]
(OR)
8. a) Write an algorithm to determine the Hamiltonian cycle in a given graph using [7M]
backtracking.
b) Explain the basic principle of Backtracking and list the applications of [7M]
backtracking.
1 of 2

|'''|'|'|''||'''||||
Code No: R2031052 R20 SET - 4

UNIT-V
9. a) Differentiate between NP-complete and NP-Hard [7M]
b) Explain the satisfiability problem and write the algorithm for the same [7M]
(OR)
10. a) Explain the classes of P and NP [7M]
b) Write the Nondeterministic sorting algorithm and analyze its complexity [7M]

es
at
pd
U
st
Fa
tu
Jn

2 of 2

|'''|'|'|''||'''||||

You might also like