0% found this document useful (0 votes)
27 views4 pages

Algorithm Analysis and Design Exam Questions

The document outlines a series of examination questions for a course on Analysis and Design of Algorithms, covering topics such as recursive and non-recursive algorithms, sorting algorithms like quick sort, recurrence relations, and graph theory. It includes tasks like writing algorithms, analyzing time complexity, and solving problems related to dynamic programming and graph cycles. The document is structured into mini tests and mid-term examinations for students in a mathematics and computer applications program.

Uploaded by

abhijeetsoni532
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)
27 views4 pages

Algorithm Analysis and Design Exam Questions

The document outlines a series of examination questions for a course on Analysis and Design of Algorithms, covering topics such as recursive and non-recursive algorithms, sorting algorithms like quick sort, recurrence relations, and graph theory. It includes tasks like writing algorithms, analyzing time complexity, and solving problems related to dynamic programming and graph cycles. The document is structured into mini tests and mid-term examinations for students in a mathematics and computer applications program.

Uploaded by

abhijeetsoni532
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

23204o3| 6

Department of Mathematics, Bioinformatics and Computer Applications


Subject: Analysis and Design of Algorithms Code: CA-303
Mini Test- August 2024
Q1 Discuss in detail about mathematical analysis of recursive and non 25
recursive algorithm.
Q2 Write an Algorithm for quick sort to sort A,L,G,0,R,I,T,H,M in 25
alphabetical order.
Q3 Solve following recurrence using Recursion tree method 25
T(n) = 3T(n/4) + O(n)
04 Given a singly linked list, a position and an element, the task is to 25
Write a program to insert that element in a linked list at a given
position and calculate its time and space complexity.
2320yo3|lG
Maulana Azad National Institute of Technology, Bhopal
Department of Mathematics, Bioin formatics and Computer Applications
Mid Term Examination, Septem ber-2024
Course: MCA Semester: III
Subject: Analysis & Design of Algorithm Subject Code: CA-303
Time: 90 Minutes Max. Marks: 20
Note: Attempt all questions. Allquestions carry equal marks.
1. . (A) Solve the recurrence relation using (B) Consider the following code. 3+2
back substitution method.
int i,j,k,n:
(7T(G)+ bn? ifn> 2, b>0 for( i=2; i<=n; izi2)
T(n) =
for(j=1: je=n: jt+)
C
if n < 2 for(k=1; ke=n; k=k+j)
print("Hello"):
Compute the time complexity of
above code?

Write the quick sort algorithm and show how the following data set can be sorted by 5
quick sort for 78, 23, 31, 88, 43, 55, 67, 55. Asume the complexity of partition
algorithms is O(Vn), find the best case and worst-case time complexity.

3.(A} You have been given a directed weighted graph of Nvertices labeled from Ito N' 3
and 'M' edges. Each edge connecting two nodes 'u' and 'v' has a weight 'w' denoting
the distance between them. Your task is to detect whether the graph contains a
negative cycle or not. A negative cycle is a cycle whose edges are such that the sum
of their weights is a negative value. Consider an example as given below:

State the Job Sequencing with deadlines problem. Find an optimal sequence to the 2
n=5 Jobs where profits (P1, P2, P3, P4, PS) =(20, 15, 10, 5, 1) and deadlines
(d1,d2,d3,d4,d5) = (2,2,1,3,3)
Give the Pseudo code for the Prim's algorithm and apply the same to find the 5
minimum spanning tree of the graph shown below:
1
3
5 5
Name of Student: Mlenog Scholar No.: 23031|6
MAULANA AZAD NATIONAL INSTITUTE OF TECHNOLOGY, BHOPAL
Department of Mathematics, Bioinformatics & Computer Applications
End Term Examination, November 2024
Course: MCA Semester: II

Subject: Analysis & Design of Algorithm Subject Code: CA 303


Max. Marks: 50
Time: 3.00 Hours

Note: Attempt all questions. All questions carry equal marks.


Marks
Q. No. Questions

1.(a of algorithms. Discuss the


Explain the significance of asymptotic notation in the analysis Big-Omega), and explain
different types of asymptotic notations (Big-O, Big-Theta, and 4
how each notation is used to describe the time complexity of an algorithm.
1.(b) yCompute the Big Ocomplexity for the ii)Solving recurrence
following algorithm. T(n) = 4T(Vn) + log'n
Public static int fun( int number){ Assume that T(n) is constant for n<-2.
if ( number < 2) Make your bounds as tight as possible,
return number; and justify your answer. 3+3
int sum =0;
for (int i=1; i< number; i*=2 )
sum +=1;
return fun(number - 1) + sum;}
shortest
2.(ay Write an algorithm using the idea of Breadth-First Search (BFS) to find a
(directed) cycle containing a given vertex v. Prove that your algorithm finds a shortest 5
cycle. What are the time and space requirements of your algorithm?
2.( Explain how the divide and conquer approach can be applied to efficiently compute the
power of a number. Provide an algorithm for computing x" using divide and conquer, and in5

analyze its time complexity.


3.(a) Apply the bottom-up dynamic programming algorithm to solve the given knapsack
problem: (capacity W= 6)
item weight value
3 S25
2 S20
3 $40
4 5 S50
S15
prove that:
i) its time efficiency is O(nW).
ii) its space efficiency is O(n W).
Design an efficient algorithm to find the closest value to a given target number in a
3.(9) sOred array of n istinct integers.
[Example: Array: 2,5,6,7,8,8,9
Target number: 5 Output: 5
Target number: 11 Output: 9
Target :number: 4 Output: 5]
time complexity of
Write down a clean pseudocode for your algorithm. Also analyse the
your algorithm
Consider a variant of the Merge Sort algorithm where instcad of dividing the array into
two approximately equal parts, it is divided into three equal parts. Each part is
recursively sorted, and then the three sorted arrays are merged together.
i) Outline the modified MERGE-THREE (A, p, q, r, s) procedure, where A is arn array
and p, q,r, and sare indices into the array such thatp<= q<r<s. 5
ii) Discuss the possible benefits or drawbacks of such a division, especially concerning
the merge step.
iii)Provide a conjecture about the time complexity of this modified algorithm
compared to the standard merge sort. Is it better, worse, or the same, explain?
4.(bY Write a MATRIX-CHA IN ORDER algorithm using top down approach. Four matrices
MI, M2, M3 and M4 of dimensions pxq. qxr, rxs and sxt respectively can be multiplied
is several ways with different number of total scalar multiplications.
For example, when multiplied as ((MI X M2) X (M3 X M4)), the total number of 5
multiplications is pqr + rst + prt. When multiplied as (((MI X M2) X M3) X M4), the
total number of scalar multiplications is pqr prs + pst. If p = 10, q = 100, r = 20, s = 5
and t = 80, then the number of scalar multiplications needed is
5.(a. Solve the all-pairs shortest-path problem for the digraph with the following weight
matrix:
2 1 8
3 2 5
4
3
l3
5.( Derive time complexity of job sequencing with deadlines. Obtain the optimal solution 5
when n=5, (p1, p2,..)=(20,15,10,5,1) and (d1,d2,..)=(2,2,1,3,3).

You might also like