Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
30 views62 pages

MCS 031

Uploaded by

Aditya Ghosh
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)
30 views62 pages

MCS 031

Uploaded by

Aditya Ghosh
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
You are on page 1/ 62

No.

of Printed Pages : 5 MCS-031

MCA (Revised)
Term-End Examination 12240
December, 2011

MCS-031 : DESIGN AND ANALYSIS OF


ALGORITHM

Time : 3 hours Maximum Marks : 100


Note : Question No. 1 is compulsory. Attempt any three
from the rest of the questions.

1. (a) Explain the relation/difference between a 2


problem and its instance through an
example of each.
(b) State and describe any one of the following 2
two problems :
(i) The Four - Colour Problem
(ii) The Fermat's Last Theorem
(c) State any four characteristics of an
algorithm, with an appropriate examples.
(d) Let Lx j denote floor function of x and Fx1 4
denote ceiling function of x. Find values
of :
(i) a.4.] (ii)
(iv) r 9.81

MCS-031 1 P.T.O.
(e) Using Insertion Sort or Bubble Sort (state 4
before starting the solution, which algorithm
for sorting, you are using), sort the following
sequence of integers in decreasing order :
85 36 34 109 49 36
(f) Arrange the following growth rates in 4
increasing order : 0 (4 n ), 0(n4), 0(1),
0(n3 logn), where '0' denotes 'big oh'.
(g) Using Principle of Mathematical Induction,
prove that 30+31+ D is equal to

12
1 1 (3n + 1 _
1) for all n 1.

(h) Explain how Binary Search Method finds 4


or fails to find the given value 43 in the
sorted array :
9, 13, 76, 27, 36, 49, 58, 79, 86.
(i) Write important properties of Depth - first 4
search strategy for traversing a tree and cite
an example of its use.
(j) Explain the essential idea of Dynamic 4
Programming. How does Dynamic
Programming differ from Divide and
conquer approach for solving problems ?
(k) Available currency notes in India are : 4
Rupee 1, 2, 5, 10, 20, 50, 100, 500 and 1000.
Explain how to make Rupees 289 by using
minimum number of currency notes.

MCS-031 2
2. (a) Discuss the three control mechanisms in an 10
algorithm :

(i) Direct sequencing

(ii) Selection

(iii) Repetition

(b) Define the function f(n) = an recursively, 5


where a is a constant real number and
n > 0 is an integer.

(c) Compare the following sorting algorithms 5


on the basis of comparasion of keys and
number of assignments :

(i) Selection sort

(ii) Insertion sort

3. (a) Multiply the following two matrices A and 8


B using Strassen's algorithm :

[ 5 61 1— 7 61
A = — 4 3] ; B [ 5 9]

(b) By taking a suitable example of a tree with 12


at least ten nodes, explain the three rules of
traversal :

(i) Pre - order traversal


(ii) In - order traversal
(iii) Post - order traversal

MCS-031 3
4. (a) Let C(n, k) = li-k1 denote the number of 12

combinations of k things out of ti given


things. Let
C(i, o) =1 for all i= 0, 1, 2, ..., n and
C(o, j) =0 for all j =1, 2, ..., lc.
Explain, using Dynamic Programming, how
to compute C (n, k) for positive integers
n and k.
(b) Using Prim's algorithm, find a minimal 8
spanning tree for the graph, given as
follows :

5. (a) Define the following, with at least one 6


appropriate example :
(i) Directed Graph
(ii) Single - Source Shortest Path Problem

MCS-031 4 P.T.O.
(b) Find a regular expression for each of the 6
following languages :
(i) (a, b, ab, ba, abba, baa, ...}
(ii) (A, a, abb, abbbb, ....I
(c) Define the following : 8
(i) Halting Problem
(ii) Undecidable Problem

MCS-031 5
No. of Printed Pages : 4 MCS-031
MCA (Revised)

lc) Term-End Examination

N14 December, 2012


V)
MCS-031 : DESIGN AND ANALYSIS OF
ALGORITHMS
Time : 3 hours Maximum Marks : 100
Note : Question No.1 is compulsory. Attempt any three from
the rest of questions.

1. (a) (i) Prove that function f (x) = 5x4 + 7x +3


is 0 (x4). Is f (x) also 0 (x4) ? Explain.
5+2=7
(ii) Arrange the following growth rates in 3
increasing order of time :
0(x3), 0(2x), 0(x2), 0(,5 log x),
0(x log x), 0(x2 log x)
(b) (i) Differentiate between dynamic 5
programming and greedy approach
to solve different problems.
(ii) Write a recursive function to multiply 5
two natural numbers.
(c) (i) Define a Kleene Star (*) of a language 7
L. Prove that if L is context free then
L* is also context free.

MCS-031 1 P.T.O.
(ii) Explain the difference between Push 3
Down Automata (PDA) and Finite
Automata (FA).

(d) (i) Define 'Halting Problem" of Turing


Machines.

(ii) Show stepwise sorting of elements


using Heapsort algorithm to the
following max heap.

2. (a) (i) Define ambiguity in Context-Free 4


Grammar (CFG). Show that the
grammar :

E--->E+E/E*E/a is ambiguous.

(ii) If L1 and L2 are two Context-Free 3


languages, then show that L1.L2 is also
Context - Free language.

MCS-031 2
(b) Use Prim's algorithm to construct a 8
minimum spanning tree from the following
graph (by using starting node A).

(c) Write a short note on NP-hard problems. 5

3. (a) Explain the complete steps of Strassen's 10


algorithm for multiplying two (n x n)
matrices.

Show that the Running time of Strassen's


Algorithm is 0 (n2.81).

(b) Build regular grammar and corresponding 10


finite automata (FA) for the following
languages over the alphabet {a, b}.

(i) Language in which words do not end


with ab.

(ii) Language having even number of a's.

MCS-031 3 P.T.O.
4. (a) Describe 0-1 Knapsack problem. Which 7
approach among greedy algorithm or
dynamic programming is applicable for this
problem ?
(b) Write a Dijkstra's algorithm for single source 10
shortest path problem. Apply Dikstra's
Algorithm for the following graph :

(c) What is the best case, average case and 3


worst case running time of merge sort ?

5. (a) (i) Explain the purpose of randomization 4


of quicksort.
(ii) What is the best case running time of 4
quicksort ? In which situation does it
occur ?
(b) Why do we perform amortized analysis of 5
a problem ?
(c) Define 0 notation and 0 notation. Explain, 7
how these two notations are different.

MCS-031 4
No. of Printed Pages : 4 MCS-031
MCA (Revised)
Term-End Examination

O December, 2013

c\1 MCS-031 : DESIGN AND ANALYSIS OF


ALGORITHMS

Time : 3 hours Maximum Marks : 100


Note : Question No.1 is compulsory. Attempt any three from
the remaining questions.

1. (a) What is an algorithm ? Explain 6


characteristics of an algorithm with the help
of an example.

(b) What is big 0 notation ? Find 0 (f(x)) for 4


3x3 + 2x2 + 4x.

(c) What is dynamic programming ? How it is 8


different from greedy technique of solving
problems ? Also give a greedy solution for
the change making problem, considering the
denominations :

{500, 200, 100, 50, 10, 5, 2, 1}

(d) Sort the following list using insertion sort. 6


Show all intermediate stages while sorting :

70, 40, 60, 80, 20, 6

MCS-031 1 P.T.O.
(e) Write algorithm of Depth-First Search and 6
trace how Depth First-Search traverses the
graph given below, when starting node is
A:

What is a heap ? Explain how a heap is built, 5


using a simple example.
List and explain any five properties of 5
regular expressions.

2. What is minimum spanning tree ? Write 10


Prim's algorithm for finding minimum
spanning tree and evaluate its time
complexity. Also find minimum spanning
tree of the following graph, using Prim's
algorithm :
7

MCS-031 2
(b) What is binary search ? Explain its time 10
complexity. Consider an array
A= [2, 5, 9, 20, 25, 30, 60]. Find the average
number of comparisons made by binary
search for successful search in array A's and
'unsuccessful search in array A'.

3. (a) What is Single - Source Shortest Path 10


Problem (SSSPP) ? Explain Dijkstra's
algorithm for SSSPP. Also find the minimum
distances of all the nodes from node A,
which is taken as the source node for the
following graph :

(b) Explain the meaning and the language 6


described by each of the following
expression :
(i) (a + b)*
(ii) ab*a*(a + b)
(iii) ab (a + b)*
Where is Kleene closure.
(c) Explain NP-hard problem with an example. 4

MCS-031 3 P.T.O.
4. (a) What is a Turing Machine ? Design a Turing 8
Machine that recognizes language L of all
strings over 1= {a, b} such that : anbn, n 3 1.
(b) What is topological sort ? Explain its 6
application with an example.
(c) What is Quick Sort ? Explain/analyse the 6
average case time complexity of Quick Sort.

5. (a) Draw the recursion tree for the following, 4


also write the following in 0 notations

T(n) = 4T(--1)+n2

(b) Prove that the Halting Problem is 6


undecidable.
(c) Explain the following problems, together 10
with their respective significance.
(i) Undecidable problem
(ii) NP-complete problem

MCS-031 4
No. of Printed Pages : 4 MCS-031

MCA (Revised)
11324 Term-End Examination
December, 2014

MCS-031 : DESIGN AND ANALYSIS OF


ALGORITHMS

Time : 3 hours Maximum Marks : 100


Note : Question number 1 is compulsory. Answer any
three questions from the rest.

1. (a) (i) Write an- algorithm to build a heap


from a given sequence.

(ii) Illustrate the heap sort algorithm on


the sequence <10, 5, 12, 6, 9, 2, 8, 16>.
6+6

(b) (i) Solve the recurrence equation

{ 2T(21 + 0(n2 ), n > 1


T(n) =
1 n<_1

(ii) Prove that f(n) = 2n3 + 3n + 5 is


0(n3).
MCS-031 1 P.T.O.
(iii) Solve the recurrence

-1- ) + 1 for (n 2)
T(n) = T (1
2

=1 n < 2. 4+4+4

(c) (i) List the major differences between


Divide and Conquer and dynamic
programming design techniques for
solving problems.

(ii) Define fractional Knap-Sack problem,


and give a greedy algorithm to solve
this problem efficiently. 5+5
(d) Give a recursive function to find the height
of a binary tree. What is the running time
of this algorithm ? 6

2. (a) What is depth first search ? Give the DFS


traversal for the following graph, starting
with node 'a'.

MCS-031 2 P.T.O.
(b) Identify the tree edges, back edges and
forward edges. 6
(c) Give an algorithm for topological sort.
Obtain a topological ordering for the
following graph : 8

3. (a) Explain the Kruskal-algorithm for


Minimum Spanning Tree construction.
Derive the running time of the algorithm. 10
(b) Show the MST corresponding to the
following adjacency matrix representation
of a graph : 10

a b c d e
a — 1 15 — 5
b 1 — 2 — 10
c 15 2 — 8 6
d — — 8 — 3
e 5 10 6 3 —

MCS-031 3 P.T.O.
4. (a) Define Regular Languages. Write regular
expression corresponding to the following
languages over alphabet {a, b}.
(i) Strings with even length.
(ii) Strings with odd number of a's and
even number of b's. 8
(b) Write context free grammar for the
following languages.
(i) Even palindromes over {a, IA.
(ii) Odd palindromes over {a, la). 6
(c) If Li and L2 are context free languages,
prove that Li U L2 is also context free. 6

5. (a) Define the Class P, NP and NP-complete


problems.
(b) Show a polynomial time reduction from the
Clique problem to the Vertex Cover
problem by giving an example. 9
(c) Give the formal definition of a Turing
machine. 5

MCS-031 4 11,000
No. of Printed Pages : 4 MCS-031

MCA (Revised)
N Term-End Examination
00
June, 2011
C
,MCS-031 : DESIGN AND ANALYSIS OF
ALGORITHM

Time : 3 hours Maximum Marks : 100


Note : Question No. 1 is compulsory. Attempt any three
from the rest of the questions.

1. (a) Arrange the following growth rates in 4


increasing order : 0 (3n), 0 (n2), 0 (1),
0 (n log n)
(b) Briefly discuss three basic actions and 4
instructions that build a program in Von
Newmann architecture machine.
(c) Write a recursive algorithm that finds the 4
sum of first n natural numbers.
(d) Explain briefly The Fermat's Last Theorem. 4
(e) Using Principle of Mathematical Induction, 4
Prove that the sum 20 + 21 +4... + 2" is
2n+1_ 1 for all n31.
(f) Using Insertion Sort or Bubble Sort, sort the 4
following sequence in increasing order :
35, 37, 18, 15, 40, 12

MCS-031 1 P.T.O.
(g) Define Knapsack Problem and cite one 4
instance of the problem.
(h) Consider a (hypothetical) country in which 4
only notes available are of denominations
10, 40 and 60. Using Greedy algorithm, how
do we collect an amount of 80.
(i) Briefly explain Kruskal's OR Prim's 4
algorithm for finding minimal spanning tree
of a graph.
(j) Name four undecidable problems, each with 4
brief description.

2. (a) Using Dijkstra's algorithm, find the 10


minimum distances of all the nodes from
node 'b' which is taken as the source node,
for the following graph.

(b) Find a regular expression for the language 5


{A,a,abb,abbb,abbbbbb,....}
(c) Briefly discuss Chomsky classification for 5
Grammars.

MCS-031 2
3. (a) Trace how BFS (Breadth - First Search) 8
traverses, i.e, discovers and visits the graph
given below when starting at node A.

(b) Write pseudo-code for Depth-First search. 5

(c) Find the value of (12)31 using not more than 7


SIX multiplications and/or divisions.

4. (a) Write a program that computes the length 6


of the diagonal of a right - angled triangle,
the length of the two sides of which are
given.

(b) For the function f (x) = 4x3 + 6x + 1 show 6


that (i) f (x) = 0 (x4) but (ii) x4 # 0 (f (x))

(c) Sort the following sequence of numbers


using Quick Sort : 8, 6, 4, 12, 11, 5, 7 and 9.

MCS-031 3 P.T.O.
5. (a) Design a Turing Machine that recognises the 10
languages of all strings of even lengths over
the alphabet {c, d}.

(b) For each of the following pairs of lists, 10


discuss whether PCP (Post Correspondence
Problem) has a solution :

(i) List A= (b, b a b b b, b a)

and List B = (b b b, b a, a)

(ii) List C = ( a b, b, b) and

D = (a b b, b a, b b)

MCS-031 4
No. of Printed Pages : 4 MCS-031

MCA (Revised)
Term-End Examination
June, 2012
N
CO
C.) MCS-031 : DESIGN AND ANALYSIS OF
ALGORITHM

Time : 3 hours Maximum Marks : 100


Note : Question No. 1 is compulsory. Attempt any three from
the remaining questions.

1. (a) Write Euclid's algorithm for finding Greatest 4


Common Divisor (G.C.D) of two natural
numbers m and n.
(b) Let fact (n) =1 * 2 * 3 * n where '*' 4
denotes product of two integers and n is a
natural number. Give a recursive definition
of fact (n).

(c) Name at least four well-known techniques 2


for solving problems algorithmically.
(d) For the function f(x) = 3x3 + 2x2 + 1, show 2
that f(x) = 0(x3) where '0' denotes 'big oh'.
(e) Explain how binary search method finds or 4
fails to find the number 25 in the sorted
list : 8, 12, 26, 35, 48, 57.

MCS-031 1 P.T.O.
(f) Explain how the nodes of the following the 4
graph will be traced using breadth first
search, starting at node 'a':

(g) Explain the method of pre-order traversal 4


of a tree, using a suitable example of a tree,
with at least eight nodes.
(h) Using Principle of Mathematical Induction, 4
show that sum of first n natural numbers is
n (n +1)/2.
(i) Explain the essential idea of Dynamic 4
Programming. How does Dynamic
Programming differ from Divide and
Conquer approach for solving problems ?
(j) Using selection sort, sort the following 4
sequence of numbers, in the increasing
order :
15, 12, 18, 24, 13, 27,
(k) Name four undecidable problems, along 4
with their special significance.

MCS-031 2
(a) Write an algorithm that finds the real roots, 5
if any, of a quadratic equation :
ax2 +bx +c =0,
Where a # 0, b and c are real numbers.
(b) Explain Chomsky classification for 5
grammers, with an appropriate example.
(c) Write a recursive algorithm to find the sum 5
of first n natural numbers.
(d) Sort the following list using Merge Sort : 5
7, 9, 10, 8, 4, 6, 5.

3. (a) Find solution of the recurrence equation, 5


given as follows :
F(n) — 4F(n —1) + 4F(n — 2) = 0
(b) Trace how Depth First Search Traverses the 7
following tree, when starting at node B :

(c) Explain each of the following, with an 8


appropriate example :
(i) Minimax Problem
(ii) Topological Sort

MCS-031 3 P.T.O.
4. (a) Find the value of (12)31, using not more than 6
SIX (6) multiplications and/or divisions.
(b) Using either Prim's algorithm or Kruskal's 8
algorithm, find a minimal spanning tree for
the graph given as follows :

(c) Explain the meaning of each of the 6


following expression :
(i) (a + b)*
(ii) a* b a* b a*
(iii) (a + b)* a b
Where denotes Kleene Closure.
5. (a) Find a grammer for the following language : 8
ambn; m, nEN, n > m }
(b) Explain each of the following problems, 12
together with their respective significance.
(i) Halting Problem
(ii) Post Correspondence Problem
(iii) Undecidable Problem

MCS-031 4
No. of Printed Pages : 3 MCS-031
MCA (Revised)
G
C \I Term-End Examination
co
O June, 2014

MCS-031 : DESIGN AND ANALYSIS OF


ALGORITHMS
Time : 3 hours Maximum Marks : 100
Note : Question No. 1 is compulsory. Attempt any three from
the remaining questions.

1. (a) What is big 0 notation ? How is it different 4


from ci notation ?
(b) Give an analysis of merge-sort. For 6
simplicity, assume that the number of
elements i.e. n is an exact power of two.
(c) Explain limitations of Strassen's Algorithm 5
for matrix multiplication.
(d) Use Master's method to find tight 5
asymptotic bounds for the following
recurrence :

T(n) T (nA) + n
Give a divide and conquer based algorithm 4
to find ith largest element in an array of
size n.
What is regular expression ? Write a regular 6
expression over 1= {a, b} to generate all
string that start with a and end with two
b's.

MCS-031 1 P.T.O.
(g) Write binary search algorithm and evaluate 6
its time complexity in the best, average and
worst cases.
(h) Explain NP- complete problem with the help 4
of an example.

2. (a) Find the topological ordering of the 6


following graph :

(b) Write Kruskal's algorithm and determine its 8


time complexity.
(c) Represent the following graph using 6
(i) Array ; and (ii) Adjancy List

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.

MCS-031 2
(d) Consider the CFG : 5
S-->SS IX aXaX1A
X bX1/\
Explain the language generated by this CFG

4. (a) What is Push Down Automata ? How is it 5


different from Finite Automata.
(b) What is MinMax Algorithm ? Explain how 10
Alpha-Beta pruning helps in improving
MinMax algorithm.
(c) What is best case analysis ? Perform the 5
best case analysis for Quick Sort.

5. (a) Explain each of the following, with an 12


appropriate example :
(i) NIM/ Marienbad Game
(ii) Principle of Mathematical Induction
(iii) Halting Problem
(b) Trace how Depth First Search Traverses the 8
following tree, when starting at node A.

MCS-031 3
No. of Printed Pages : 4 I mc s-03 11
MCA (Revised)
Term-End Examination
December, 2018

MCS-031 : DESIGN AND ANALYSIS OF


ALGORITHMS

Time : 3 hours Maximum Marks : 100

Note : Question no. 1 is compulsory. Attempt any three


questions from the rest.

1. (a) Differentiate betWeen P and NP class of


problems with example of each. 5
(b) Write an algorithm that finds the real
roots, if any, of a quadratic equation
ax2 + bx + c = 0, where a 0, b and c are
real numbers.
(c) By using Principle of Mathematical
Induction, show that n3 — n, is divisible by
6, where n is a non-negative integer.
(d) Sort the following sequence of numbers
using Bubble sort :
15, 10, 13, 9, 12, 17.
Find the total number of comparisons
required by the algorithm in sorting the
list. 6
MCS-031 P.T.O.
Explain the "Principle of Optimality" in
dynamic programming with suitable
example.
Compute x29 by using divide and conquer
technique. 5
Define Regular Expression. Find the
Regular Expression for the following Finite
Automata : 8

0, 1

2. (a) Apply Dynamic programming to multiply


the following chain of matrices :
M1, M2, M3 and M4 with respective .

dimensions (5 x 10), (10 x 3), (3 x 7), (7 x 15). 10


(b) Differentiate between Kruskal's and Prim's
algorithms. Apply Prim's algorithm to find
the minimum spanning tree for the
following graph : 10
5

MCS-031
3. (a) Write Euclid's algorithm to find the GCD of
two natural numbers m and n.

(b) Write Merge Sort Algorithm. Apply the


same to sort the array of elements
15, 10, 5, 9, 7, 20, 25, 18, 16. 10

(c) Show that the context-free grammar


S S+S I S*S I a is ambiguous.

4. (a) Define 0-Notation. Show that


(i) 3x2 + 2x + 1 = 0(x2)
(ii) 2x3 + x + 5 0(x4) 10

(b) Write Dijkstra's Algorithm. Using


Dijkstra's Algorithm, find the minimum
distances of all the nodes from starting
node a. 10

MCS-031 3 P.T.O.
5. (a) Write short notes on any three of the
following : 3x5=15
(i) Kleene Closure
(ii) Push-down Automata (PDA)
(iii) Chomsky's Classification of Grammar
(iv) Amortize Analysis

(b) Find context-free grammar for the


following : 5
(i) L = (am bn m, n E N, n > m}
(ii) L= (am b cn I n E N)

MCS-031 4 8,500
No. of Printed Pages : 4 MCS- 031
MCA (Revised)
-zzr,
Term-End Examination
June, 2013

MCS-031 : DESIGN AND ANALYSIS OF


ALGORITHMS
Time : 3 hours Maximum Marks : 100
Note : Question No. 1 is compulsory. Attempt any three from
the rest of questions.

1. (a) (i) Write an algorithm to sort the given 6


array of numbers using Insertion Sort
and explain the necessary steps. Also
write the time complexity in the worst
case.
Prove that function : 6

f (x)=2x3+ x2+ 100 is 0(x3).

(b) (i) Solve the following recurrence 5


relation :

fn — fn_1 — fn_2= 0 s.t. fo=o


h=1
(ii) Prove that the running time of binary 5
search algorithm in worst case is
0 (log2 n).

MCS-031 1 P.T.O.
(c) (i) Define undecidability. List any three 5
undecidable problem.
(ii) Discuss, why do we use dynamic 5
programming approach to solve
matrix chain multiplication problem.
(d) (i) There are five bottles of medicine, 5
namely A, B, C, D and E. The
capacity of each bottle in term of
number of tablets it can hold is given
below :
Bottle A : 10 tablets, Bottle B: 60 tables,
Bottle C : 130 tablets,
Bottle D : 240 tablets, Bottle E : 100
tablets.
Give a greedy approach to store
560 tablets by using minimum number
of bottles.
(ii) Analyse the time complexity for the 3
following :
for (i = 1 ; ; i= i*2)
for (j=1 ; ; j+ +)
Count = count + 2 ;

2. (a) If L1 and L2 are regular languages. Prove 5


that Li U L2 is also regular.
(b) Write a recursive function to calculate the 5
sum of all elements in an integer array.

MCS-031 2
(c) Define a Context-Free Grammar (CFG). 10
Write a CFG for the following language.
(i) L= {am bn : m>n, m, n
(ii) L = foxoR : 10E {a, where WR is
a reverse of w.
3. (a) What is "principle of optimality" in 10
Dynamic Programming ? Explain how
dynamic programming can be used to solve
a chain of matrix multiplication ? Apply
Dynamic Programming to multiply the
following (4) matrices. <M1, M2, M3, M4>
with dimensions <(15, 3), (3, 8), (8, 9),
(9, 7)>.
(b) Write an algorithm for Quick Sort. Analyse 10
the Running time of Quick Sort in Best and
worst case.

4. (a) Use Kruskal's algorithm to construct a 5


minimum spanning tree from the following
graph.

MCS-031 3 P.T.O.
(b) Define 0/I Knapsack Problem. Using 10
Dynamic programming. Solve the
following 0/I Knapsack problem.
No. of objects n=5,
Capacity of Knapsack, M=16
Weight 2 3 6 5 9
Profit 2 7 15 20 12
(c) Write an algorithm for Topological Sort. 5

5. (a) Sort the following elements using Heap Sort : 7


47, 29, 82, 11, 48, 32, 28, 17, 65, 36
Show each step, while creating a heap and
processing a heap.
(b) Use breadth first search to traverse the 5
following graph by using C as the starting
node.

(c) Write an algorithm to multiply given two 8


n-bit decimal number X = xn _1 2....x1 xo
and Y = yn — 1 — 2-- yo, using Divide and
Conguer method. Also analyse the time
complexity of the algorithm used ?

MCS-031 4
No. of Printed Pages : 4 I MCS-031
MCA (Revised)
Term-End Examination
00996 June, 2018

MCS-031 : DESIGN AND ANALYSIS OF


ALGORITHMS

Time : 3 hours Maximum Marks : 100

Note : Question no. 1 is compulsory. Attempt any three


questions from the rest.

1. (a) Multiply the following n-digit decimal


numbers, x and y, using the Karatsuba
technique, where
x = xn-1 , x0

Yn-1 , Yn-2' ..., 3r0. 7

(b) Sort the following sequence in ascending


order using Insertion sort :
(28, 13, 12, 25, 38, 11, 15, 9, 36)
(c) Differentiate between Asymptotic
notations, 0 (Big "oh"), S1 (Big "omega")
and 9 (Theta) notations. 6

MCS-031 1 P.T.O.
(d) Define Minimum Cost Spanning Tree
(MCST). Find the MCST using the Prim's
algorithm for the following graph :
9
10 15

18
11
(e) Construct a Deterministic Finite Automata
(DFA) for the following Regular Expression : 5
(0 + 1)* (00 + 11) (0 + 1)*
(f) Write the Recursive and Iterative
algorithm to compute the Greatest
Common Divisor (GCD) of two numbers
X and Y. 5
(g) Explain the V. Strassen's matrix
multiplication method of multiplying two
matrices of size (n x n). Show that its
running time is 0 (n 1og27). 6
2. (a) Write the Dijkstra's algorithm for shortest
path. Apply the same for the following
graph, to find the shortest path from
node 8
16

24

17

MCS-031 2
(b) Explain the Chomsk s classification of
grammars. 6

(c) Differentiate between the Greedy and


Dynamic programming approaches to solve
a problem. List 3 problems which use these
approaches, respectively. 6

3. (a) Write the Context-Free Grammar (CFG) for


the following language :
(i) L = {anbnicnidn I m, n > 1}
L = {0)&0R o E {a, b}* and (0R is the
reverse of col.

(b) Explain the 0/1 Knapsack problem. Solve


the following 0/1 Knapsack problem :
Given number of objects n = 6
Capacity of Knapsack (M) = 12
(p1, P2, P6) = (1, 6, 18, 22, 28, 43)
and (w 1, w2, w6) = (1, 2, 5, 6, 7, 10).
Where pi's and wi 's are the profits and
weights of the corresponding objects.

(c) Apply the dynamic programming


method to solve the following
chain-matrix-multiplication :
(M1, M2, M3 , M4) with dimensions
(15 x 6, 6 x 50, 50 x 9, 9 x 12)
MCS-031 3 P.T.O.
4. (a) Solve the following recurrence using the
Master method : 6

n
(i) T(n) = 3T (— ) + n log n
4

(ii) T(n) = 2T (Li-) + n


2

(b) Find the best case and worst case time


complexity of Quick Sort by writing their
recurrence relation. 7

(c) Define Turing Machine (TM). Design . TM


for the language
L = fan bn n 11. 7

5. (a) Differentiate between P, NP, NP-Complete


and NP-Hard problem.

(b) Define Push-Down Automata (PDA).


Design a PDA that accepts the language
EVEN PALINDROME over E = fa, b}.
(c) Write short notes on the following : 6
(i) Halting Problem of TM
(ii) Post Correspondence Problem (PCP)

MCS-031 4 7,000
No. of Printed Pages : 3 MCS-031

MCA (Revised)
Term-End Examination
December, 2015

MCS-031 : DESIGN AND ANALYSIS OF


ALGORITHMS
Time : 3 hours Maximum Marks : 100

Note : Question no. 1 is compulsory. Attempt any three


questions from the rest.

1. (a) Write recursive binary search algorithm


and analyse its run time complexity. 7

(b) Solve the recurrence :


T(n) = 2T (n/2) + n; n 2
= 1 ;n<2. 4

(c) Using Dijkstra's algorithm, find the


minimum distances of all the nodes from
source node 'a' for the following graph :

MCS-031 1 P.T.O.
(d) Construct a Turing Machine (TM) to accept
all languages of palindromes on alphabet
= (a, b).

(e) Explain matrix multiplication using


dynamic programming. 10

(f) What is minimax principle ? Explain with


the help of an example. 6

2. (a) Obtain the minimum cost spanning tree for


the following graph using Prim's algorithm. 5
3 4

(b) Obtain the DFS tree for the graph given in


Q.no. 2(a); considering node Oa as root
node. 5

(c) Explain the Chomsky's classification of


grammars. 10

3. (a) Enumerate any five well-known techniques


for designing algorithms for solving
problems.

MCS-031 2
(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. 8
(c) For any set S of strings prove that
S* = (S*)* = S** 7

4. (a) Arrange the following growth rates in


increasing order : 5

0(n3), 0(3n), 0(n log n), 0(1), 0(log n).

(b) For the function


f(x) = 4x3 + 6x + 5,
show that (i) f(x) = 0(x 4)
but (ii) x4 # 0(fix)). 5
(c) What is Pushdown Automata (PDA) ?
Build a PDA that accepts the language
even palindrome. 10

5. (a) What is Satisfiability problem ? Explain


briefly. 5
(b) Prove that the running time of binary
search algorithm in worst case is 0(log 2n). 5

(c) Using Bubble Sort, sort the following


sequence in increasing order : 5
11, 21, 6, 14, 8, 12, 28, 32.
(d) Write a note on regular languages. 5

MCS-031 3 14,000
No. of Printed Pages : 4
I MC S-031
MCA (Revised)
Term-End Examination
December, 2016

MCS-031 : DESIGN AND ANALYSIS OF


ALGORITHMS

Time : 3 hours Maximum Marks : 100

Note : Question no. 1 is compulsory. Attempt any three


from the remaining questions.

1. (a) Use Mathematical Induction to prove that


E n(n + 5
2
i =1

(b) For a problem P, two algorithms A l and A2


have time complexities T 1(n) = 5n2 and
T2 (n) = 100 n log n. Find the range for n,
the size of instance of the given problem P,
for which Al is more efficient than A2. 5

(c) Define the big theta notation. Show that


n2 + 3 log n = 0(n2). 5

MCS-031 1 P.T.O.
(d) (i) Explain the bottom-up build heap
procedure.
(ii) Illustrate heapsort algorithm on the
sequence <10, 5, 12, 25, 2, 8, 13, 7>. 10
(e) Solve the following recurrence equations : 10
(i) T(n) = 2T(n/2) + 0(n)
(ii) T(n) = T(n - 1) + 0(n)

(f) Write a Regular expression to generate


strings of even length over the alphabet
E = fa, b). 5

2. (a) Give a divide and conquer algorithm to find


the ith smallest in an unsorted list of n
integers. Show that the algorithm works in
0(n) time. 10

(b) Write a recursive function to calculate the


sum of all elements in an integer array. 5

(c) Explain any two applications of DFS


traversal algorithm.

3. (a) Given the currency coins of denomination


1, 4 and 6. Design a dynamic programming
algorithm to obtain minimum number of
coins for a given amount. 10

MCS-031 2
(b) Using Prim's algorithm, find a Minimal
Spanning tree for the graph given below : 10
2

4. (a) (i) Write a context-free grammar to


generate all palindromes of even
length over the alphabet E = {a, 5
(ii) Derive the parse tree and derivation
for the string a abb aa . 5

(b) (i) Explain the algorithm to find the


Strongly Connected Component in an
undirected graph.
(ii) Find the Strongly Connected
Components in the following graph : 5

MCS-031 3 P.T.O.
5. (a) Explain the following : 10
(i) Undecidable problems
(ii) Turing machines

(b) Define the Class P, NP and NP-complete


problems. 5

(c) Write a Turing machine to recognize the


language of all strings of even length over
the alphabet (a, b}. 5

MCS-031 4 9,000
No. of Printed Pages : 4 I MCS-031 I
MCA (Revised)
Term-End Examination
June, 2016

06022
MCS-031 : DESIGN AND ANALYSIS OF
ALGORITHMS

Time : 3 hours Maximum Marks : 100

Note : Question no. 1 is compulsory. Attempt any three


questions from the rest. Parts of the same question
. may be attempted together,

1. (a) Explain five characteristics of an algorithm


briefly.

(b) Write and explain recursive algorithm to


find the factorial of any given number
n ?_ O.

(c) Explain the importance of asymptotic


analysis for running time of an algorithm
with the help of an example.

(d) Briefly describe Chomsky classification for


Grammars. 5

MCS-031 1 P.T.O.
(e) Using Dijkstra's algorithm, find the
minimum distances of all the nodes from
node 'a' which is taken as the source node,
for the following graph : 10

(0 "The best-case analysis is not as important


as the worst-case analysis of an algorithm."
Yes or No ? Justify your answer with the
help of an example. 10

2. (a) Explain how greedy approach is useful to


find the solution to fractional knapsack
problem.

(b) Solve the following recurrence relation : 5

fn fn - 1 - fn - 2 =
such that fo = 0 and f1 = 1.

(c) Explain Turing Machine (TM)' as a


computer of functions, with the help of an
example. 8

MCS-031
3. (a) Using Prim's algorithm, find a minimal
spanning tree for the graph given below : 10
2 A 3

6
(b) Sort the following sequence of numbers,
using Selection Sort. Also find the number
of comparisons and copy operations
required by the algorithm in sorting this
list : 10
20 5 15 8 6 28

4. (a) Using Depth First Search (DFS) traverse


the following graph by using A as the
starting node 5

MCS-031 3 P.T.O.
(b) Define f2 notation used for comparing two
functions.
For ftx) = 2x3 + 3x2 + 1
h(x) = 2x3 — 3x2 + 2
show that
(1) f(x) = a (x3)
(ii) x2 f2 (h(x)) 5

(c) What is dynamic programming ? Explain


briefly the optimal substructure property of
a dynamic programming problem. 5

(d) What is NP-complete problem ? Is it


necessary that every NP-complete problem
must also be a NP-hard problem ? Justify. 5

5. (a) Write an algorithm for Heap Sort and


analyse its Best and Worst run time
complexity. 10

(b) Define a Turing Machine. 5


(c) Consider the CFG :
S SS/X.aXaX/A
X —* bX/A
Find the language generated by this CFG. 5

MCS-031 4 7,000
No. of Printed Pages 3 mc ga31 1
MCA (Revised)
Term-End Examination
June, 2017
03612
MCS-031 : DESIGN AND ANALYSIS OF
ALGORITHMS

Time : 3 hours Maximum Marks : 100

Note : Question no. 1 is compulsory. Attempt any three


from the remaining questions.

1. (a) Use mathematical induction to prove the


following expression :
n
2i 2n+1 — 1
i =1

(b) Define Big-0 and Big Omega notation, and


prove that
f(n) = 3 log n + log log n = 0 (log n). 6
(c) Write a regular expression to generate
strings of odd lengths over the alphabet
E (a, W. 5
(d) Solve the following recurrence equations :
(i) T(n) = 2T(n/2) + n
(ii) T(n) = T(n/2) + 1
T(n) = T(n/2) + n

MCS-031 P.T.O.
(e) Write an algorithm for Merge Sort.
Analyze its time complexity. 10

(f) What is the essence of Greedy technique ?


Give an example. 5

2. (a) Obtain the DFS traversal for the following


graph :

Identify the tree edges, back edges and


cross edges.

(b) Explain any three applications of DFS


traversal.

(c) Explain Kruskal's algorithm to compute


the minimum cost spanning tree.

3. (a) Explain how dynamic programming can be


used to solve matrix chain multiplication.
Apply the algorithm to multiply the
following : 10
3 matrices, < M 1 , M2, M3 > with
dimensions < (15, 3), (3, 10), (10, 2) >

MCS-0 3 1 2
(b) Give a' divide and conquer based algorithm
to find the ith smallest element in an array
of size n: Trace your algorithm to find 3 rd
smaletinhry
A = 110, 2, 5, 15, 50, 6,.201. 10

4. (a) Define Regular Languages. Write regular


expressions for the following : 9
(i) Strings of even length over the
alphabet E = {a, b}.
(ii) Strings with odd number of a's and
even number of b's over the alphabet
E = fa,
(b) Explain Chomsky's classification for
grammars. •
(c) Show that the following CFG is ambiguous :
E-->E+E
E_*E*E
E --> aib

(a) Define a Turing machine. 5


(b) If L1 and L2 are context-free languages,
then prove that L 1 U L2 is also context-free. 5
(c) Explain the term Polynomial time
reduction'. Explain how the clique problem
can be transformed to the vertex cover
probleth. 10

MCS-031 3,500
No. of Printed Pages : 4 MCS-031 I
MCA (Revised)
Term-End Examination
December, 2017
0-4290

MCS-031 : DESIGN AND ANALYSIS OF


ALGORITHMS

Time : 3 hours Maximum Marks : 100

Note : Question no. 1 is compulsory. Attempt any three


questions from the rest.

1. (a) Show that the partition problem is NP. 5

(b) For the functions f(x) = 2x3 + 3x2 + 1 and


h(x) = 2x3 — 3x2 + 2, prove that : 2x5=10
(i) f(x) = 0(h(x))
flx) O(x2)
(c) Show that the state entry problem is
undecidable. 5

(d) If S = {a, aa, aaa}, T = {bb, bbb}, then prove


that ST = {abb, abbb, aabb, aabbb, aaabb,
aaabbb}. 5
(e) Differentiate between NP-Complete and
NP-Hard problems. Give one example for
each. 5
MCS-031 1 P.T.O.
(f) Analyze the time complexity of binary
search in worst case. 5

(g) Construct a Deterministic Finite Automata


(DFA) over = {a, b}, which accepts all
strings over that start and end with the
same letter. 5

2. (a) Explain Strassen's Matrix Multiplication


Algorithm and apply the same to multiply
the following two matrices : 10

[5 6 —7 6
A= ,B=
—4 3 5 9

(b) Solve the following 0/1 knapsack problem


using dynamic programming : 10
Number of objects n = 6
Weights of objects wi = (1,2,5,6,8,10)
Profit of objects p i = (1,6,18,22,30,43)
Capacity of knapsack, M = 12

3. (a) Multiply the following two numbers using


Karatsuba's method : 5
1026732 and 732912

(b) Define Context-Free Grammar (CFG). Find


CFG for the language
L = fanbmcn I m, n 11.
MCS-031 2
(c) Write Kruskal's Algorithm and apply the
same to find a minimum spanning tree for
the following graph : 5

(d) Solve the following recurrence relation : 5


to = 2tn _ 1 + 1, such that to = 1.

4. (a) Write short notes on any three of the


following : 3x5=15
(i) Chomsky's Classification of Grammar
(ii) Push-Down Automata (PDA)
(iii) Depth-First Search (DFS)
(iv) Asymptotic Notation (0, Q and 0)

(b) Design a Push Down Automata that


accepts the language of odd palindromes. 5

5. (a) Design a Turing Machine that accepts the


following language : 8
fanbn n 11
MCS-031 3 P.T.O.
(b) Write an algorithm for Quick Sort. Sort the
following sequence of numbers using Quick
Sort :
15, 10, 13, 9, 12, 7
Analyze the time complexity of Quick Sort
in best and worst cases. 6+6=12

MCS-031 4 8,000
No. of Printed Pages : 4 I MCS-031 I
MCA (Revised)
Term-End Examination
10423 June, 2015

MCS-031 : DESIGN AND ANALYSIS OF


ALGORITHMS
Time : 3 hours Maximum Marks : 100
Note : Question number 1 is compulsory. Attempt any
three questions from the rest.

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. 4+4
(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.
Draw the recursion tree for C(6, 4). 4
Write a recursive function to generate
C(n, k). 4
Give an algorithm based on Dynamic
Programming to solve C(n, k).
Compare the time and space
requirements of the algorithm in part
(iii). 4
MCS-031 P.T.O.
(c) (i) You are given currency of
denominations {500, 100, 50, 20, 10, 51.
Give a greedy algorithm to obtain the
minimum number of denomination for
any amount which is a multiple of 5. 6
(ii) Write a procedure to merge two -sorted
arrays. Analyze the running time of
your algorithm. 6
(d) Is the following sequence a heap ? If not,
convert it into a heap. 4
< 10, 5, 3, 8, 6, 1, 7 >

2. (a) (i) Write an algorithm to find the ith


smallest element in 0(n) time. 6
(ii) Illustrate the working of your
algorithm on the input
< 1, 5, 8, 6, 13, 4, 3 >
to find the 4th smallest element. 4
(b) (i) Define a BFS tree. Give the breadth
first traversal for the undirected
graph given below, starting from
vertex 'a'. 6

(ii) Give any two applications of Depth


first search. 4

MCS-031 2 P.T.O.
3. (a) (i) Explain Dijkstra's shortest path
algorithm. 6

(ii) Find the shortest path in the


following graph represented by
adjacency matrix, from vertex 'a'. 4

a b c d e
a — 1 15 — 5
b 1 — 2 — 10
c 15 2 — 8 6
d — — 8 — 3
e 5 10 6 3 —

(b) (i) Explain the principle of greedy


algorithm. 4

(ii) Explain Prim's algorithm for


Minimum Spanning Tree, and obtain
the MST for the graph in question
3 (a) (ii). 6

4. (a) (i) Define Finite Automata and Regular


Expression.

(ii) Write Regular Expression for the


following : 6

(1) L = (01)n, n 1.

(2) Strings that start with '1' and


end with '0'.

MCS-031 3 P.T.O.
(b) Obtain the CFG for the following : 10
(i) Strings of matching parenthesis.

(ii) Expression of the form E = (E + E) * E.


The expression contains : parenthesis,
operators : +, * and /.

5. (a) Explain the class-P, NP and NP-complete


problems. 6

(b) (i) What is undecidability ? Give an


example for an undecidable problem. 5
(ii) Design a polynomial time reduction
from the vertex cover problem to the
clique problem. 9

MCS-031 4 8,000

You might also like