MCS 031 Notes
MCS 031 Notes
MCS 031 Notes
Notes-1
1. (a) (i) Solve the recurrence equation T(n) = 2.T(n/4) + n3 for n > 1 and T(1) = 1.
Obtain the asymptotic upper bound for f(n) = (6n2-5n + 2)2.
(b) A binomial coefficient is defined by the following recurrence relation :
C(n, 0) = 1 and C(n, n) = 1 for n > 0.
C(n, k) = C(n-1, k) + C(n-1, k-1) for n>k> O.
(i) Draw the recursion tree for C(6, 4).
(ii) Write a recursive function to generate C(n, k).
(iii) Give an algorithm based on Dynamic Programming to solve C(n, k).
(iv) Compare the time and space requirements of the algorithm in part (iii).
(c) (i) You are given currency of denominations {500, 100, 50, 20, 10, 5}.Give a
greedy algorithm to obtain the minimum number of denomination for any amount
which is a multiple of 5.
(ii) Write a procedure to merge two -sorted arrays. Analyze the running time of your
algorithm.
(d) Is the following sequence a heap ? If not,convert it into a heap.
< 10, 5, 3, 8, 6, 1, 7 >
2. (a) (i) Write an algorithm to find the ith smallest element in O(n) time.
(ii) Illustrate the working of your algorithm on the input < 1, 5, 8, 6, 13, 4, 3 > to find
the 4th smallest element.
(b) (i) Define a BFS tree. Give the breadth first traversal for the undirected graph
given below, starting from vertex 'a'.
Notes-2
1. (a) Write recursive binary search algorithm and analyse its run time complexity.
(b) Solve the recurrence :
T(n) = 2T (n/2) + n; n ≥ 2= 1 ;n<2.
(c) Using Dijkstra's algorithm, find the minimum distances of all the nodes from
source node 'a' for the following graph :
(d) Construct a Turing Machine (TM) to accept all languages of palindromes on
alphabet ∑= (a, b).
(e) Explain matrix multiplication using dynamic programming.
(f) What is minimax principle ? Explain with the help of an example.
2. (a) Obtain the minimum cost spanning tree for the following graph using Prim's
algorithm.
(b) Obtain the DFS tree for the graph given in Q.no. 2(a); considering node 'a' as root
node.
(c) Explain the Chomsky's classification of grammars.
3. (a) Enumerate any five well-known techniques for designing algorithms for solving
problems.
(b) Sort the following elements using Heap Sort :
10, 28, 46, 39, 15, 12, 18, 9, 56, 2.
Show each step, while creating a heap and processing a heap.
(c) For any set S of strings prove that S* = (S*)* = S**.
Notes-3
1. (a) What is big O notation ? How is it different from notation ?
(b) Give an analysis of merge-sort. For simplicity, assume that the number of
elements i.e. n is an exact power of two.
(c) Explain limitations of Strassen's Algorithm for matrix multiplication.
(d) Use Master's method to find tight asymptotic bounds for the following recurrence
:
T(n) T (n/2)+n
(e) Give a divide and conquer based algorithm to find ith largest element in an array
of size n.
(f) What is regular expression ? Write a regular expression over ∑= {a, b} to generate
all
string that start with a and end with two b's.
(g) Write binary search algorithm and evaluate its time complexity in the best, average
and worst cases.
(h) Explain NP- complete problem with the help of an example.
3. (a) Sort the given list using bubble sort and show the steps involved in the process :
2, 7, 5, 10, 21, 3
(b) Write Euclid's algorithm for finding Greatest Common Divisor (G.C.D) of two
natural numbers m and n.
(c) What is the benefit of preconditioning a problem space ? Explain using an
example.
(d) Consider the CFG :
S→SS |XaXaX|∧
X→ bX|/∧
Explain the language generated by this CFG
4. (a) What is Push Down Automata ? How is it different from Finite Automata.
(b) What is MinMax Algorithm ? Explain how Alpha-Beta pruning helps in
improving MinMax algorithm.
(c) What is best case analysis ? Perform the best case analysis for Quick Sort.
Also available:-
BCA all semester new solved assignments Download