Daa Question Bank Srmist
Daa Question Bank Srmist
UNIT 1
Introduction-Algorithm Design, Fundamentals of Algorithms, Correctness of
algorithm, Time complexity analysis, Insertion sort-Line count, Operation count,
Algorithm Design paradigms, Designing an algorithm, And its analysis-Best, Worst
and Average case, Asymptotic notations Based on growth functions. O,O,Ө, ω, Ω
Mathematical analysis, Induction, Recurrence relations , Solution of recurrence
relations, Substitution method, Solution of recurrence relations, Recursion tree,
Solution of recurrence relations, Examples
PART A
2. While solving the problem with computer the most difficult step is ______.
A. describing the problem
B. finding out the cost of the software
C. writing the computer instructions
D. testing the solution
Answer:- C
3. ______ solution requires reasoning built on knowledge and experience
A. Algorithmic Solution C. Random Solution
B. Heuristic Solution D. Brute force Solution
Answer: - B
Answer: - A
12. Consider a linked list of n elements. What is the time taken to insert an
element after an element pointed by some pointer?
A. (1) C. (log2 n)
B. (n) D. (n log2 n)
Answer A
13. If the address of A[1][1] and A[2][1] are 1000 and 1010 respectively and each
element occupies 2 bytes then the array has been stored in order.
A. row major C. matrix major
B. column major D. none of these
Answer A
14. The time factor when determining the efficiency of algorithm is measured by
A. Counting microseconds
B. Counting the number of key operations
C. Counting the number of statements
D. Counting the kilobytes of algorithm
Answer B
15. Time complexities of three algorithms are given. Which should execute the
slowest for large values of N?
A. (n log n) C. O(log n)
B. O(n) D. O(n2)
Answer B
16. Which one of the following is the tightest upper bound that represents the
number of swaps required to sort n number using selection sort?
A. (log n) C. (n log n)
B. O(n) D. O(n2)
Answer B
17. How many comparisons are needed for linear Search array when elements are
in order in best case?
A. 1 C. n+1
B. n D. n-1
Answer A
18. The complexity of Bubble sort algorithm is__________
A. O(n) C. O(n2)
B. O(log n) D. O(n log n)
Answer : C
A. O(n) C. O(n2)
B. O(nlogn) D. O(2n)
Answer D
25. A function in which f(n) is Ω(g(n)), if there exist positive values k and c such
that f(n)>=c*g(n), for all n>=k. This notation defines a lower bound for a
function f(n):
A. Big Omega Ω (f) C. Big Oh O (f)
B. Big Theta θ (f) D. Big Alpha α (f)
Answer A
PART C
1 . Describe the steps in analyzing & coding an algorithm.
2 . Enumerate the problem types used in the design of algorithm.
3 . What are the steps that need to be followed while designing and analyzing
algorithm?
4 . Explain the fundamental of algorithmic problem solving.
5 . Use the most appropriate notation to indicate the time efficiency class of
sequential
algorithm in the worst case, best case and the average case.
6 . Consider the following algorithm for the searching problem.
Algorithm:
Linear search (A[0,...n-1],key)
//Searches an array for a key value by linear search
//Input: Array A[0..n-1] of values and a key value to search
//Output: Returns index if search is successful
for i<-0 to n-1 do
if(key==A[i])
return i
7 . Explain some of the problem types used in the design of algorithm.
8 . Define time complexity and space complexity. Write an algorithm for adding ‘n’
natural numbers and find the time and space required by that algorithm.
9 . Explain the general framework for analyzing the efficiency of algorithm.
10 . Write the Insertion Sort algorithm and estimate its running time.
11 . What is space complexity? With an example, explain the components of fixed and
Variable part in space complexity?
12 . Show how to implement a stack using two queues. Analyze the running time of
stack operations.
13 . Discuss the properties of asymptotic notations.
14 . Explain the various asymptotic notations used in algorithm design. With an
Example
15 . Give the definition and graphical representation of O notations.
16 . Define asymptotic notations. Distinguish between Asymptotic notation and
conditional asymptotic notation.
17 . Prove that for any two functions f(n) and g(n), we have
f(n) = θ (g(n)) if and only if f(n) = O (g(n)) and f(n) = Ω(g(n)).
18 . Write the linear search algorithm and analyze for its best worst and average case
time
Complexity.
19 . Discuss about recursive and non-recursive algorithms with example.
20 . What is the general plan for time efficiency of recursive algorithm and find the
number
of binary digits in the binary representation of positive decimal integer find
recurrence relation and complexity.
21 . State the general plan for analyzing the time efficiency of non-recursive
algorithms and
explain with an example.
22 . Compare the order of the growth of the following.
i)(1/2) n(n-1) and n2
ii)log2n and √n
iii)n! and 2n
23 . Find the closest asymptotic tight bound by solving the recurrence equation
T(n)=8T(n/2)+n2 with (T(1)=1) using Recursion tree method. [Assume T(1) € θ (1)]
24 . Give an algorithm to check whether all the elements in a given array of n-
elements are
distinct, find the worst case complexity of the same.
25 . Explain the towers of Hanoi problem and solve it using recursion
26 . Prove the time complexity of the matrix multiplication is O(n 3)
27 . Define recurrence equation and explain how solving recurrence equations are
done.
28 . Solve the following recurrence relations.
I. x(n)=x(n-1)+5 for n>1, x(1)=0
II. x(n)=3x(n-1)for n>1, x(1)=4
III. x(n)=x(n-1)+n for n>0, x(0)=0
IV. x(n)=x(n/2)+n for n>1, x(1)=1 (solve for n=2k)
V. x(n)=x(n/3)+1 for n>1, x(1)=1 (solve for n=3k)
29 . Solve the following recurrence relations.
I. x(n)=x(n-1)+n for n>0,x(0)=0
II. x(n)=x(n/2)+n for n>1, x(1)=1 (solve for n=2k)
III. x(n)=3x(n-1) for n>1,x(1)=4
30 . Suppose W satisfies the following recurrence equation and base case (where c is
constant) : W(n)=c.n+W(n/2) and W(1)=1. What is the asymptotic order of W(n).
With a suitable example, explain the method of solving recurrence equations.
PART-A
2) Which of the following is not the required condition for binary search algorithm?
A. The list must be sorted
B. There should be the direct access to the middle element in any sub list
C. There must be mechanism to delete and/or insert elements in list.
D. Number values should only be present
ANSWER: C
4) ____________order is the best possible for array sorting algorithm which sorts n
item.
A. O (n logn)
B. O (n2)
C. O (n+logn)
D. O (logn)
ANSWER: C
10) The operation that combines the element is of A and B in a single sorted list C with
n=r+s element is called ________
A. Inserting
B. Mixing
C. Merging
D. Sharing
ANSWER: C
13 )The time complexity of a quick sort algorithm which makes use of median, found
by an O(n) algorithm, as pivot element is
a) O(n2)
b) O(nlogn)
c) O(nloglogn)
d) O(n)
ANSWER: B
14) Which of the following algorithm design technique is used in the quick sort
algorithm?
a) Dynamic programming
b) Backtracking
c) Divide-and-conquer
d) Greedy method
ANSWER: C
16 )For merging two sorted lists of size m and n into sorted list of size m+n, we require
comparisons of
a) O(m)
b) O(n)
c) O(m+n)
d) O(logm + logn)
ANSWER: C
20) Which algorithm is a divided and conquer algorithm that is asymptotically faster:
a. Simple algorithm
b. Specific algorithm
c. Strassen algorithm
d. Addition algorithm
ANSWER: C
24). which of the following method is used for sorting in merge sort?
a) Merging
b) Partitioning
c) Selection
d) Exchanging
ANSWER: A
26) What is the runtime efficiency of using brute force technique for the closest pair
problem?
a) O (N)
b) O (N log N)
c) O (N2)
d) O (N3 log N)
ANSWER: C
27) What is the basic operation of closest pair algorithm using brute force technique?
a) Euclidean distance
b) Radius
c) Area
d) Manhattan distance
ANSWER: A
29) Find the maximum sub-array sum for the given elements.
{-2, -1, -3, -4, -1, -2, -1, -5, -4}
a) -3
b) 5
c) 3
d) -1
ANSWER: D
PART C
UNIT III
Introduction-Greedy and Dynamic Programming, Examples of problems that can be
solved by using greedy and dynamic approach Huffman coding using greedy
approach, Comparison of brute force and Huffman method of encoding Knapsack
problem using greedy approach, Complexity derivation of knapsack using greedy
Tree traversals, Minimum spanning tree - Greedy, Kruskal's algorithm - greedy
Minimum spanning tree - Prim's algorithm, Introduction to dynamic programming
0/1 knapsack problem, Complexity calculation of knapsack problem Matrix chain
multiplication using dynamic programming, Complexity of matrix chain
multiplication Longest common subsequence using dynamic programming,
Explanation of LCS with an example Optimal binary search tree (OBST)using
dynamic programming, Explanation of OBST with an example
PART A
1. ------------- is a Boolean-valued function that determines whether x can be
included into the solution vector
a) Overlapping subproblems
b) Fleasible solution
c) Memoization
d) Greedy
Answer B
2. Trees with edge with weights are called ------------
a) weighted tree
b) unweighted tree
c) bruteforce
d) Greedy
Answer A
3. ---------------- is to determine an optimal placement of booster
a) Weighted tree
b) Vertex
c) Tree Vertex Splitting Problem (TVSP)
d) Greedy
Answer C
4. The order in which TVS visits that computes the delay values of the nodes
of the tree is called the---------------.
a)treeorder
b) inorder
c) preorder
d) postorder
Answer D
5. Algorithm TVS takes ------------ time, where n is the number f
nodes in the tree
a)O(N)
b)Ω( n log n)
c)O (n2log n)
d)O( n log n)
Answer A
Answer A
Answer A
Answer B
9. The two-way merge pattern scan be represented by------------
a) Weighted tree
b) Vertex
c) Binary merge tree
d) Greedy
Answer C
a) greedy technique
b) divide-and-conquer technique
c) dynamic programming technique
d) the algorithm combines more than one of the above techniques
Answer A
11. The function Tree of Algorithm uses the ------- stated to obtain a two-way
merge tree for n file
a) divide-and-conquer technique
b) greedy rule
c) dynamic programming technique
d) the algorithm combines more than one of the above techniques
Answer B
12. A decode tree is a-------------- in which external nodes represent messages.
Answer B
13. The -------------in the code word for a message determine the branching
needed at each level of the decode tree to reach the correct external
node.
a) binary bits
b) decoder
c) encoder
d) binary bytes
Answer A
14. The cost of decoding a --------is proportional to the number of bits in the
code
a) binary bits
b) code word
c) data
d) binary bytes
Answer B
15. What is the edges on the shortest paths from a vertex v to all
remaining vertices in a connected undirected graph G form a
spanning tree of G is called?
a) MST
b) shortest-path spanning tree
c) binary tree
d) AVL tree
Answer B
16. ---------------is an algorithm design method that can be used when the
solution to a problem can be viewed as the result of a sequence of
decisions.
a) Dynamic Programming
b) Greedy method
c) Huffman coding
d) Tree traversal
Answer A
Answer A
Answer A
Answer D
Answer C
22. Which of the following problems is NOT solved using dynamic programming?
a) 0/1 knapsack problem
b) Matrix chain multiplication problem
c) Edit distance problem
d) Fractional knapsack problem
Answer D
24. In Knapsack problem, the best strategy to get the optimal solution,
where Pi, Wi is the Profit, Weight associated with each of the Xith object
respectively is to
a)Arrange the values Pi/Wi in ascending order
b)Arrange the values Pi/Xi in ascending order
c)Arrange the values Pi/Wiin descending order
d)Arrange the values Pi/Xiin descending order
Answer D
Answer B
Answer B
27. The multistage graph problem can also be solved using the ----------
a) backward approach
b) forward approach
c) brute force approach
d) right sub trees
Answer B
28. The all-pairs ----------problem is to determine a matrix A such that A(i,j)is
the length of a shortest path from i to j.
a) backward approach
b) forward approach
c) brute force approach
d) shortest-path
Answer D
29. Which of the following methods can be used to solve the Knapsack problem?
a) Brute force algorithm
b) Recursion
c) Dynamic programming
d) Brute force, Recursion and Dynamic Programming
Answer D
Answer A
31. Which of the following pairs of traversals is not sufficient to build a binary
tree from the given traversals?
a) Preorder and Inorder
b) Preorder and Postorder
c) Inorder and Postorder
d) Inorder and levelorder
Answer D
Answer D
33. Given items as {value, weight} pairs {{60, 20}, {50, 25}, {20, 5}}. The
capacity of knapsack=40. Find the maximum value output
assuming items to be divisible and nondivisible respectively.
a) 100,80
b) 110,70
c) 130,110
d) 110,80
Answer D
34. Given items as {value, weight} pairs {{40, 20}, {30, 10}, {20, 5}}. The
capacity of knapsack=20. Find the maximum value output
assuming items to be divisible
a) 60
b) 80
c) 100
d) 40
Answer A
What is the weight of the minimum spanning tree using the Prim’s
algorithm, starting from vertex a?
a) 23
b) 28
c) 27
d) 11
Answer C
36. Worst case is the worst case time complexity of Prim’s algorithm if
adjacency matrix is used?
a) O(log V)
b) O(V2)
c) O(E2)
d) O(V log E)
Answer B
Which of the following edges form the MST of the given graph using
Prim’a algorithm, starting from vertex 4.
a) (4-3)(5-3)(2-3)(1-2)
b) (4-3)(3-5)(5-1)(1-2)
c) (4-3)(3-5)(5-2)(1-5)
d) (4-3)(3-2)(2-1)(1-5)
Answer D
38. From the following given tree, what is the code word for the
character ‘a’?
a) 011
b) 010
c) 100
d) 101
Answer A
39. What will be the cost of the code if character ci is at depth di and occurs at
frequency fi?
a) cifi
b) ∫cifi
c) ∑fidi
d) fidi
Answer C
Answer C
41. The weighted array used in TVS problems for the following binary tree is
__________
a) [1,2,3,0,0,4,0,5,6]
b) [1,2,3,0,0,4,0,5,0,0,0,0,6]
c) [1,2,3,4,5,6]
d) [1,2,3,0,0,4,5,6]
Answer B
42. What is the time complexity of the brute force algorithm used to find the
longest common subsequence?
a) O(n)
b) O(n2)
c) O(n3)
d) O(2n)
Answer D
43. Find the longest increasing subsequence for the given sequence:
{10, -10, 12, 9, 10, 15, 13, 14}
a) {10, 12, 15}
b) {10, 12, 13, 14}
c) {-10, 12, 13, 14}
d) {-10, 9, 10, 13, 14}
Answer D
Answer B
45. The Breadth First Search algorithm has been implemented using the queue
data structure. One possible order of visiting the nodes of the following
graph is
a) O(1)
b) O(n)
c) O(n2)
d) O(nlogn)
Answer B
Answer A
47. The Breadth First Search algorithm has been implemented using the
queue data structure. One possible order of visiting the nodes of the
following graph is
a) MNOPQR
b) NQMPOR
c) QMNPRO
d) QMNPOR
Answer C
What is the weight of the minimum spanning tree using the Kruskal’s
algorithm?
a) 24
b) 23
c) 15
d) 19
Answer D
Answer C
PART B
1 Discuss the components of Greedy Algorithm.
2 Compare Greedy technique with dynamic programming and divide
and compare.
PART A
1. Which of the following is not a backtracking algorithm?
(A) Knight tour problem
(B) N queen problem
(C) Tower of hanoi
(D) M coloring problem
Answer: - C
2. Backtracking algorithm is implemented by constructing a tree of
choices called as?
A) State-space tree
B) State-chart tree
C) Node tree
D) Backtracking tree
Answer: - A
3. What happens when the backtracking algorithm reaches a complete
solution?
A) It backtracks to the root
B) It continues searching for other possible solutions
C) It traverses from a different route
D) Recursively traverses through the same route
Answer: - B
4. In what manner is a state-space tree for a backtracking algorithm
constructed?
A) Depth-first search
B) Breadth-first search
C) Twice around the tree
D) Nearest neighbour first
Answer: - A
5. In general, backtracking can be used to solve?
A) Numerical problems
B) Exhaustive search
C) Combinatorial problems
D) Graph coloring problems
Answer: - C
6. Which one of the following is an application of the backtracking
algorithm?
A) Finding the shortest path
B) Finding the efficient quantity to shop
C) Ludo
D) Crossword
Answer: - D
7. Who coined the term ‘backtracking’?
A) Lehmer
B) Donald
C) Ross
D) Ford
Answer: - A
8. The problem of finding a subset of positive integers whose sum is equal
to a given positive integer is called as?
A) n- queen problem
B) Subset sum problem
C) Knapsack problem
D) Hamiltonian circuit problem
Answer: - B
9. The problem of placing n queens in a chessboard such that no two
queens attack each other is called as?
A) n-queen problem
B) eight queens puzzle
C) four queens puzzle
D) 1-queen problem
Answer: - A
10. In how many directions do queens attack each other?
A) 1
B) 2
C) 3
D) 4
Answer: - C
11. Placing n-queens so that no two queens attack each
other is called?
A) n-queen’s problem
B) 8-queen’s problem
C) Hamiltonian circuit problem
D) subset sum problem
Answer: - A
12. Where is the n-queens problem implemented?
A) carom
B) chess
C) ludo
D) cards
Answer: - B
13. Not more than 2 queens can occur in an n-queens problem.
A) true
B) false
Answer: - B
14. In n-queen problem, how many values of n does not provide an
optimal solution?
A) 1
B) 2
C) 3
D) 4
Answer: - B
15. Which of the following methods can be used to solve n-
queen’s problem?
A) greedy algorithm
B) divide and conquer
C) iterative improvement
D) backtracking
Answer: - D
16. Of the following given options, which one of the following is a correct
option that provides an optimal solution for 4-queens problem?
A) (3,1,4,2)
B) (2,3,1,4)
C) (4,3,2,1)
D) (4,2,3,1).
Answer: - A
17. How many possible solutions exist for an 8-queen problem?
A) 100
B) 98
C) 92
D) 88
Answer: - C
18. How many possible solutions occur for a 10-queen problem?
A) 850
B) 742
C) 842
D) 724.
Answer: - D
19. The Knapsack problem is an example of ____________
A) Greedy algorithm
B) 2D dynamic programming
C) 1D dynamic programming
D) Divide and conquer
Answer: - B
20. Which of the following methods can be used to solve the
Knapsack problem?
A) Brute force algorithm
B) Recursion
C) Dynamic programming
D) Brute force, Recursion and Dynamic Programming
Answer: - D
21. You are given a knapsack that can carry a maximum weight of 60.
There are 4 items with weights {20, 30, 40, 70} and values {70, 80,
90, 200}. What is the maximum value of the items you can carry
using the knapsack?
A) 160
B) 200
C) 170
D) 90
Answer: - A
22. Which of the following problems is equivalent to the 0-1 Knapsack
problem? A) You are given a bag that can carry a maximum weight of W.
You are given N items which have a weight of {w1, w2, w3,…., wn} and a
value of {v1, v2, v3,…., vn}. You can break the items into smaller pieces.
Choose the items in such a way that you get the
maximum value
B) You are studying for an exam and you have to study N questions. The
questions take {t1, t2, t3,…., tn} time(in hours) and carry {m1, m2, m3,….,
mn} marks. You can study for a maximum of T hours. You can either study a
question or leave it. Choose the questions in such a way that your score is
maximized
C) You are given infinite coins of denominations {v1, v2, v3,….., vn} and a
sum S. You have to find the minimum number of coins required to get the
sum S
D) You are given a suitcase that can carry a maximum weight of 15kg. You
are given 4 items which have a weight of {10, 20, 15,40} and a value of {1, 2,
3,4}. You can break the items into smaller pieces. Choose the items in such
a way that you get the maximum value
Answer: - B
23. What is the time complexity of the brute force algorithm used to solve
the Knapsack problem?
A) O(n)
B) O(n!)
C) O(2n)
D) O(n3)
Answer: - C
24. Which of the following is/are property/properties of a dynamic
programming problem?
A) Optimal substructure
B) Overlapping subproblems
C) Greedy approach
D) Both optimal substructure and overlapping subproblems
Answer: - D
25. If an optimal solution can be created for a problem by
constructing optimal solutions for its subproblems, the problem
possesses ____________ property.
A) Overlapping subproblems
B) Optimal substructure
C) Memoization
D) Greedy
Answer: - B
26. If a problem can be broken into subproblems which are reused several
times, the problem possesses ____________ property.
A) Overlapping subproblems
B) Optimal substructure
C) Memoization
D) Greedy
Answer: - A
27. If a problem can be solved by combining optimal solutions to non-
overlapping problems, the strategy is called _____________
A) Dynamic programming
B) Greedy
C) Divide and conquer
D) Recursion
Answer: - C
28. In dynamic programming, the technique of storing the previously
calculated values is called ___________
A) Saving value property
B) Storing value property
C) Memoization
D) Mapping
Answer: - C
29. When a top-down approach of dynamic programming is applied to a
problem, it usually _____________
A) Decreases both, the time complexity and the space complexity
B) Decreases the time complexity and increases the space complexity
C) Increases the time complexity and decreases the space complexity
D) Increases both, the time complexity and the space complexity
Answer: - B
30. Which of the following problems is NOT solved using dynamic
programming?
A) 0/1 knapsack problem
B) Matrix chain multiplication problem
C) Edit distance problem
D) Fractional knapsack problem
Answer: - D
31. Which of the following problems should be solved using dynamic
programming?
A) Mergesort
B) Binary search
C) Longest common subsequence
D) Quicksort
Answer: - C
32. Time Complexity of Breadth First Search is? (V - number of vertices, E -
number of edges)
A) O(V+E)
B) O(V)
C) O(E)
D) O(VE)
Answer: - A
33. The spanning tree of connected graph with 10 vertices
contains ..............
A) 9 edges
B) 11 edges
C) 10 edges
D) 8 edges
Answer: - A
34. The Breadth First Search algorithm has been implemented using the
queue data structure. One possible order of visiting the nodes of the
following graph is
A) MNOPQR
B) NQMPOR
C) QMNPRO
D) QMNPOR
Answer: - C
35. What is the maximum height of queue (To keep track of un-explored nodes)
required to process a connected Graph G1 which contains 'N' node using BFS
algorithm?
A) (N/2)-1
B) (N/2)/2
C) N-1
D) N
Answer: - C
PART B
1. What is meant by knapsack problem?
2. Define fractional knapsack problem.
3. Write the running time of 0/1 knapsack problem.
4. Write recurrence relation for 0/1 knapsack problem
5. What is meant by travelling salesperson problem?
6. What is the running time of dynamic programming TSP?
7. State if backtracking always produces optimal solution.
8. Define backtracking.
9. What are the two types of constraints used in backtracking?
10. What is meant by optimization problem?
11. Define Hamiltonian circuit problem.
12. What is Hamiltonian cycle in an undirected graph?
13. Define 8queens problem. 8. List out the application of backtracking.
14. Define promising node and non-promising node.
15. Give the explicit and implicit constraint for 8-queen problem.
16. How can we represent the solution for 8-queen problem?
17. Give the categories of the problem in backtracking.
18. Differentiate backtracking and over exhaustive search.
19. Find optimal solution for the knapsack instance n =3,w=[20,15,15],P
=[40,25,25]and C =30
20. What is travelling salesperson problem?
21. What is the formula used to find upper bound for knapsack
problem? 22. Differentiate between back tracking and branch
and bound.
23. List out the application of branch and bound technique.
24. Analyze the time complexity for Warshall’s and Floyd’s
algorithm. 25. Test the 0/1 knapsack problem.
26. Summarize Warshall’s algorithm
27. Compare feasible and optimal solution.
28. Differentiate between DFS and BFS.
29. What is efficiency of DFS based algorithm for topological sorting
30. What are the different applications of DFS and BFS?
PART C
1. Describe the travelling salesman problem and discuss how to solve it
using dynamic programming?
2. Find the optimal solution for the given knapsack problem
.
3. Apply backtracking technique to solve the following instance of the subset
sum problem S = [1,3,4,5} and d=11 16
4. Explain subset-sum problem and discuss the possible solution
strategies using backtracking.
5. Explain N-queens problem with an algorithm.
6. Explain why backtracking is defined as a default procedure of last resort
for solving problems.
7. Explain the subset-sum problem in detail by justifying it using backtracking
algorithm. 8. Apply backtracking to the problem of finding a Hamiltonian
circuit for the following graph.
1 4 $40
2 7 #42
3 5 $25
4 3 $12
11. Discuss the solution for knapsack problem using branch and bound
technique.
12. What is branch and bound technique?Explain how knapsack problem could
be solved using branch and bound technique.Solve the following instance of the
knapsack problem by branch and bound algorithm for W=16
PART A
1. What is a Rabin and Karp Algorithm?
(A) String Matching Algorithm
(B) Shortest Path Algorithm
(C) Minimum spanning tree Algorithm
(D) Approximation Algorithm
Answer: - A
A) 1
B) 2
C) 3
D) 4
Answer: - B
22. Let X be a problem that belongs to the class NP. Then which one of the
following is TRUE?
A) There is no polynomial time algorithm for X.
B) If X can be solved deterministically in polynomial time, then P = NP.
C) If X is NP-hard, then it is NP-complete.
D) X may be undecidable.
NP Complete
Answer: - C
A) α is in P and β is NP-complete
B) α is NP-complete and β is in P
C) Both α and β are NP-complete
D) Both α and β are in P
Answer: - C
25. Which of the following algorithm can be used to solve the Hamiltonian
path problem
efficiently?
A) branch and bound
B) iterative improvement
C) divide and conquer
D) greedy algorithm
Answer: - A
29. In what time can the Hamiltonian path problem can be solved using
dynamic
programming?
A) O(N)
B) O(N log N)
C) O(N2)
D) O(N2 2N)
Answer: - D
30. How many Hamiltonian paths does the following graph have?
A) 1
B) 2
C) 3
D) 4
Answer: - A
PART B
1. Define NP hard and NP completeness.
2. Compare NP hard and NP completeness.
3. Write Short notes on “the class P and NP problem”.
4. How NP Hard problems are different from NP Complete?
5. Whether class P solves a problem in polynomial time? Justify.
6. An NP hard problem can be solved in deterministic polynomial time, how?
7. Give examples for NP Complete problems
8. State the property of NP complete problem.
9. Define adversary method.
10. Define lower bound.
11. What type of output yields trivial lower bound?
12. What is information theoretic lower bound?
13. Define complexity theory.
14. What is halting problem?
15. What is CNFs satisfiablity problem?
16. Define Matching.
17. Define a bipartite graph.
18. How will you check the stability?
19. What is stable marriage problem?
20. Define the term stable pair
21. What do you mean by perfect match in bipartite graph?
22. Write Rabin Karp string matching algorithm
23. Describe Hamiltonian cycle problem
PART C
1. Describe in detail about P and NP Problems
2. Write short notes on NP Complete Problem
3. Write short notes on the following using approximation Algorithm
i) Nearest –neighbor algorithm with example
ii) Multi fragment heuristic algorithm with example
4. Describe in detail about Twice around the tree algorithm with example
5. Explain local search heuristic with example
6. Explain Approximation Algorithms for the Travelling Salesman
Problem
7. Explain the Assignment problem in Branch and bound with Example.
8. Suggest an approximation algorithm for TSP. Assume that the cost
function satisfies the triangle inequality.
9. Using an example prove that, satisfiability of Boolean formula in 3-
Conjunctive Normal Form is NP – complete.
10. State the relationships among the complexity class algorithms with
the help of neat diagrams
11. Explain the algorithm for stable marriage problem and prove the
theorem with Example
12. Consider an instance of the stable marriage problem given by the
ranking matrix
A B C
α 1,3 2,2 3,1
β 3,1 1,3 2,2
γ 2,2 3,1 1,3
For each of its marriage matching’s, indicate whether it is stable or not
14. Write the algorithm for maximum matching in Bipartite Graphs and
prove the theorem With example
15. Explain the algorithm:
i. Blocking pair
ii. Stable marriage problem
iii. Man optimal
iv. Women optimal
16. Explain briefly on minimum weight perfect matching algorithm.
17. Explain briefly on reducing bipartite graph to net flow
18. Explain local search heuristic with example
19. Consider the following minimization problem:
DEGREE BOUNDED SPANNING TREE:
Instance: Graph G = (V,E)
Solution:: A spanning tree T of G
Value: Maximum degree of T
Goal: Find a solution with minimum value.
20. Consider the following scheduling problem. You are given n jobs where
job i is specied by an earliest start time si and a processing time pi. In
homework 1, we considered a preemptive version of this problem and
gave a greedy algorithm to give an optimal preemptive schedule. In
this problem we consider the non-preemptive version of this
scheduling problem. Here a job CANNOT be suspended but rather
must be performed in a contiguous time interval. Consider the
following heuristic for the non-preemptive problem: schedule the jobs
in the order in which they complete in an optimal preemptive schedule
starting each job as soon as the one before it completes. You are to
prove that this algorithm is a 2-approximation algorithm.
21. Using Rabin karp string matching algorithm match the given pattern P
with given string S.
P = 745
S = 745727457
22. Using KMP string matching algorithm, find the occurrence of the given
patter P in the given text T.
T ß ABABACAB
P ß ABAB