Вы находитесь на странице: 1из 31

S.V.

ENGINEERING COLLEGE FOR WOMEN


KARAKAMBADI ROAD, TIRUPATI-517507
Approved by AICTE New Delhi & Affiliated to JNTUA, Anantapuramu.

Question Bank

Subject Name : Design and Analysis of Algorithms

Subject Code : 15A05604


Unit 1
Objective Questions

1. word algorithm came from the name of the_________


a)Dennis Ritchie b)Charles babbage c)rivest d)Abi Jafer Khowarizmi
ans:d
2. Profiling is also termed as__________
a)performance Measurement b)performance analysis c) Debugging d) all
ans: a
3.which of the following is the pseudo code convention for the assignment
statement______
a)<var>=<value> b)<value>=<var> c)<value>=<var> d)<var>=<value>
ans:a
4.Recurrence relations are used mostly to find the time complexity of
_________algorithms
(a) recursive b)non recursive c) A&B d)none
ans:a
5. The time complexity of Stassen’s matrix multiplication is_______
(a)O(n) b)O(n3) c) O(n2.81) d)O(log n)
ans:c
6.In the quicksort list elements is portioned based on the________
(a)middle element b) first element c)last element d)pivot element
ans:d
6The objective function of the kruskal’s algorithm is to _____
a)Minimize the total cost of the MST b)maximize the total cost of MST
c) both a&b d)none
ans:a
7. if p is a program ,then its time complexity t(p)=compiletime+runtime
8. .Using DAC approach the problem has the direct solution ,if small(p)=1 or true
9. What is the total time needed to process n find operations.
(a )O(n) b) O(log n) c) O(1) d) O(n2)
ans:d
10. strassen’s matrix multiplication time complexity is
(a) O(2n) b)O(n3) c)O(n2.81) d) O(n2.18)
ans:c
11.I which traversal the adjacent nodes of a node are visited first
(a) preorder b) post order c) BFS d)DFS
ans:c
12.The time complexity of merge sort algorithm is______
(a) O(nlog n) b)O (logn) c)O(n2) d)O(n3)
ans:a
13.The step by step description of a process is called as______
a) algorithm b)pseudocode c) flow chart d)program
ans:a
14.The worest case of time complexity of quick is ________
(a)O(n) b)O(log n) c)O(n2) d)O(n3)
ans:c

Fill in the Blanks

1.BFS uses......... traversal:->Level order

2. DFS uses......... traversal :->Pre order

3.If for every pair of vertices, i, j there exists a path from i to j and a path from j to i then the
directed graph is .......:->strongly connected

4.An undirected graph is called ......if for every pair of vertices there exists a path between
them

.:->connected

5.A maximal bi connected sub graph is a .....:->bi connected component

True or False

1. BFS uses Pre Order traversal. F


2. The complexity of the an algorithm is related with time taken to execute algorithm. T
3. Computational algorithm is with following properties definite and effective T
4. In pseudo code conventions comment of a line is start with // T
5. Two sets A and B are disjoint, if they have elements in common F
6. If A ^ A = A then it belongs to idenpotency law. T

Two marks Questions

1. What is performance measurement?


Ans: Performance measurement is concerned with obtaining the space and the time
requirements of a particular algorithm.
2. What is an algorithm?
Ans:An algorithm is a finite set of instructions that, if followed, accomplishes a particular
task. In addition, all algorithms must satisfy the following criteria:
1) input
2) Output
3) Definiteness
4) Finiteness
5) Effectiveness.

3. Define Program.

Ans:A program is the expression of an algorithm in a programming language.Sometimes


works such as procedure, function and subroutine are used synonymously program.
4. Write the For LOOP general format.
Ans:The general form of a for Loop is
For variable : = value 1 to value 2 step Step do
{
statement1
….
…..
….
statement n
}

5. What is recursive algorithm?


Ans: An algorithm is said to be recursive if the same algorithm is invoked in the body. An
algorithm that calls itself is Direct recursive. Algorithm A is said to be indeed recursive if it
calls another algorithm, which in turn calls A.
6. What is space complexity?
Ans:The space complexity of an algorithm is the amount of memory it needs to run to
completion.
7. What is time complexity?
Ans:The time complexity of an algorithm is the amount of computer time it needs to run to
completion.
8. Give the two major phases of performance evaluation
Ans:Performance evaluation can be loosely divided into two major phases:
(i) a prior estimates (performance analysis)
(ii) a Posterior testing(performance measurement)
9. Define input size.
Ans: The input size of any instance of a problem is defined to be the number of words(or the
number of elements) needed to describe that instance.
10. Define best-case step count.
Ans: The best-case step count is the minimum number of steps that can be executed for the
given parameters.
11. Define worst-case step count.
Ans: The worst-case step count is the maximum number of steps that can be
executed for the given parameters.
12. Define average step count.
Ans: The average step count is the average number of steps executed an instances with the
given parameters.
13. Define the asymptotic notation “Big on” (0)
Ans: The function f(n) = O(g(n)) iff there exist positive constants C and no such that f(n)≤ C
* g(n) for all n, n ≥n0.
14. Define the asymptotic notation “Omega” ( Ω ).
Ans:The function f(n) =Ω (g(n)) iff there exist positive constant C and no such that f(n) C *
g(n) for all n, n ≥ n0.
15. Define the asymptotic t\notation “theta” (θ )
Ans:The function f(n) =θ (g(n)) iff there exist positive constant C1, C2, and no such that C1
g(n)≤ f(n) ≤ C2 g(n) for all n, n ≥ n0.
16. Define Little “oh”.
Ans:The function f(n) = 0(g(n))
Iff Lim f(n) = 0 n - ∝ g(n)
17. Define Little Omega.
Ans:The function f(n) = ω (g(n))
Iff Lim f(n) = 0 n - ∝ g(n)
18. Write algorithm using iterative function to fine sum of n numbers.
Ans:Algorithm
sum(a,n)
{
S : = 0.0
For i=1 to n do
S : - S + a[i];
Return S;
}
19. Write an algorithm using Recursive function to fine sum of n numbers,
Ans:Algorithm Rsum (a,n)
{
If(n≤ 0) then
Return 0.0;
Else Return Rsum(a, n- 1) + a(n);
}
20. Define the divide and conquer method.
Ans:Given a function to compute on „n‟ inputs the divide-and-comquer strategy suggests
splitting the inputs in to‟k‟ distinct susbsets, 1k n, yielding „k‟ subproblems. The
subproblems must be solved, and then a method must be found to combine subsolutions into
a solution of the whole. If the subproblems are still relatively large, then the divide-and
conquer strategy can possibly be reapplied.
21. Define control abstraction.
Ans:A control abstraction we mean a procedure whose flow of control is clear but whose
primary operations are by other procedures whose precise meanings are left undefined.
22. Write the Control abstraction for Divide-and conquer.
Ans:
Algorithm DAnd(ρ)
{
if small(p) then return
S(ρ);
else
{
divide P into smaller instance ρ 1, ρ 2, ρ k, k ≥ 1;
Apply D and C to each of these subproblems
Return combine (DAnd C(ρ1) DAnd C(ρ2),----, DAnd ((ρk));
}
}

23. What is the substitution method?


Ans:One of the methods for solving any such recurrence relation is called the
substitution method.
24. What is the binary search?
Ans:If „q‟ is always chosen such that „aq‟ is the middle element(that is, q=[(n+1)/2), then the
resulting search algorithm is known as binary search.
25. Give computing time for Bianry search?
Ans:In conclusion we are now able completely describe the computing time of binary search
by giving formulas that describe the best, average and worst cases.
Successful searches
θ(1) θ(logn) θ(Logn)
best average worst
unsuccessful searches θ(logn) best, average, worst
26. Define external path length?
Ans:The external path length E, is defines analogously as sum of the distance of all external
nodes from the root.
27. Define internal path length.
Ans:The internal path length „I‟ is the sum of the distances of all internal nodes from the
root.
28. What is the maximum and minimum problem?
Ans:The problem is to find the maximum and minimum items in a set of „n‟
elements.Though this problem may look so simple as to be contrived, it allows us
todemonstrate divide-and-comquer in simple setting.
29. What is the Quick sort?
Ans: Quicksort, the division into subarrays is made so that the sorted subarrays do not need to
be merged later.

30. Write the Anlysis for the Quick sot.


Ans: In analyzing QUICKSORT, we can only make the number of element comparisions
c(n). It is easy to see that the frequency count of other operations is of the same order as C(n).
31. Is insertion sort better than the merge sort?
Ans:Insertion sort works exceedingly fast on arrays of less then 16 elements, though for large
„n‟ its computing time is O(n2).
32. Write a algorithm for straightforward maximum and minimum?
Ans:algorithm straight MaxMin(a,n,max,min)
//set max to the maximum and min to the minimum of a[1:n]
{
max := min: = a[i]; for i = 2 to n do
{
if(a[i] >max) then max: = a[i];
if(a[i] >min) then min: = a[i];
}
}

33. Give the recurrence relation of divide-and-conquer?


Ans:The recurrence relation is
T(n) = g(n)
T(n1) + T(n2) + ----+ T(nk) + f(n)

35. What are internal nodes?


Ans:The circular node is called the internal nodes.

Long Answer type Questions

1) Give brief description about performance measurement.


2) Define an algorithm. Explain the different criteria that satisfy the algorithm.
3) Briefly explain about asymptotic notations.
4) What are the different techniques to represent an algorithm? Explain?
5) Give an example to solve the towers of Hanoi problem.
6) Write an algorithm to implement magic square.
7) Explain the different areas of research where the algorithms can be applied.
8) Explain how to identify the repeated elements.
9) Write miller-primality testing algorithms.
10) Discus the different approaches to find the time complexity of algorithms.
11) Explain the sorting of elements by using merge sort technique?
12) Present an iterative algorithm for binary search?
13) Explain in detail about the stressen’s matrix multiplication?
Unit 2
Objective Questions

1. Greedy method is used to solve which of the following knapsack problem?


(a)0/1 knapsack b)fractional part knapsack c) both d) none

2.The magnetic tape follows which type of data accessing?


(a) sequential access b) Random access c) both d)none
ans:a
3. The greedy and dynamic programming algorithms are used to obtain
_____________solution.
Ans:optimum
4. OBST means_______________
a) Optimal binary search tree b)Operational binary search tree
c)Object binary search tree d)None
ans:a
5. .Forward approach of multi-stage graph problem is also called as Backward reasoning
6.If k is an intermediate vertex then length of the shorytest path Ak(I,j)=min{Ak-1(I,j)
7.If T is a spanning tree of graph G=(V,E) then T=(V,E’)
8.Greedy solutions exist for
(a) no problems b)all problems c)some problems d) no optimization problems
ans:c
9.The time complexity of Kruskal’s algorithm is ______
(a)O(log(n) b)O(n) c)O(n2) d)O(n3)
ans:a
10.If atleast one path exists between every pair of vertices I a gragh it is known as_____
(a) complete graph b)acyclic graph c)connected graph d)Euler graph
ans:c

Fill in the Blanks

1. A graph G is ………if it contains no articulation point:->binconnectcd


2. A vertere V in a connected graph G is an ………. point if the deletion of vertere V
together with all cdges incident to V disconnects the graph into two or more non-
empty components.:->articulation point.
3. In kruskal’s algorithm following data structure is used :->heap
4. The total time needed to process the n - 2 finds is :-> O(n2)
5. The programs on the tape can be stored to minimize the MRT :->lf programs are
stored in the increasing order of length.
6. The time required to process a FIND for an element at level i of a tree is……..:->
O(n2)
7. The Big Oh notation gives the limit :->lowest maximum of the function
8. The function 4n+2 can be expressed by using big Oh notation as follows :->O(n)
9. The Big Oh notation gives the limit :->lowest maximum of the function
10. In case of Ackeruann's function A (P I V) = …………if P>=1 and q>=2 :-> A(P-
1,A(PIV-1))
True or False

1. kruskal’s algorithm heap data structure is used. T


2. The running time of DFS is Ɵ (V + E) T
3. The maximum number of comparisons required to search an a by using binary search with 64
elements is: 6 T
4. The difference between merge sort and quick sort is use of external array T
5. If AUB + BUA then it belong to compound law.

Two marks Questions

1.What is meant by feasible solution?


Ans:Given n inputs and we are required to form a subset such that it satisfies some given
constraints then such a subset is called feasible solution.
2. Write any two characteristics of Greedy Algorithm?
Ans:* To solve a problem in an optimal way construct the solution from given set of
candidates.
* As the algorithm proceeds, two other sets get accumulated among this one set contains the
candidates that have been already considered and chosen while the other set contains the
candidates that have been considered but rejected.
3.Define optimal solution?
Ans:A feasible solution either maximizes or minimizes the given objective function is called
as optimal solution
4. What is Knapsack problem?
Ans:A bag or sack is given capacity n and n objects are given. Each object has weight wi and
profit pi .Fraction of object is considered as xi (i.e) 0<=xi<=1 .If fraction is 1 then entire
object is put into sack. When we place this fraction into the sack we get wixi and pixi.
5. Define weighted tree.
Ans:A directed binary tree for which each edge is labeled with a real number (weight) is
called as weighted tree.
6. What is the use of TVSP?
Ans:In places where the loss exceeds the tolerance level boosters have to the placed.Given a
network and loss tolerance level the tree vertex splitting problems is to determine an optimal
placement of boosters.
7. What is the Greedy choice property?
Ans:* The first component is greedy choice property (i.e.) a globally optimal solution can
arrive at by making a locally optimal choice.
* The choice made by greedy algorithm depends on choices made so far but it cannot depend
on any future choices or on solution to the sub problem.
* It progresses in top down fashion.
8. What is greedy method?
Ans:Greedy method is the most important design technique, which makes a choice that looks
best at that moment. A given „n‟ inputs are required us to obtain a subset that satisfies some
constraints that is the feasible solution. A greedy method suggests that one can device an
algorithm that works in stages considering one input at a time.
9. What are the steps required to develop a greedy algorithm?
Ans:* Determine the optimal substructure of the problem.
* Develop a recursive solution.
* Prove that at any stage of recursion one of the optimal choices is greedy
choice. Thus it is always safe to make greedy choice.
* Show that all but one of the sub problems induced by having made the
greedy choice are empty.
* Develop a recursive algorithm and convert into iterative algorithm.
10. What is activity selection problem?
Ans:The „n‟ task will be given with starting time si and finishing time fi. Feasible Solution is
that the task should not overlap and optimal solution is that the task should be completed in
minimum number of machine set.
11. Write the specification of TVSP
Ans:Let T= (V, E, W) be a weighted directed binary tree
Where V vertex set
E edge set
W weight function for the edge.
W is more commonly denoted as w (i,j) which is the weight of the edge <i,j> ε E.
12. Define forest.
Collection of sub trees that are obtained when root node is eliminated is known as forest
13 .What does Job sequencing with deadlines mean?
Ans:* Given a set of „n‟ jobs each job „i‟ has a deadline di such that di>=0
and a profit pi such that pi>=0.
* For job „i‟ profit pi is earned iff it is completed within deadline.
* Processing the job on the machine is for 1unit of time. Only one machine is available.
14. Define post order traversal.
Ans:The order in which the TVSP visits the nodes of the tree is called the post order
traversal.
15. Write the formula to calculate delay and also write the condition in which the node gets
splitted?
Ans: To calculate delay
d(u)=max{d(v)+w(u, v)} v ε c(u)
The condition in which the node gets splitted are:
d(u)+w(u ,v)>δ and also d(u) is set to zero.
16. What is meant by tolerance level?
Ans:The network can tolerate the losses only up to a certain limit tolerance limit.
17. When is a task said to be late in a schedule?
Ans:A task is said to be late in any schedule if it finishes after its deadline else a task is early
in a schedule.
18. Define feasible solution for TVSP.
Ans:Given a weighted tree T(V,E,W) and a tolerance limit δ any subset X of V is a feasible
solution if d(T/X)<= δ.
19. Define optimal solution for TVSP.
Ans:An optimal solution is one in which the number of nodes in X is minimized.
20. Write the general algorithm for Greedy method control abstraction.
Ans: Algorithm Greedy (a, n)
{
solution=0;
for i=1 to n
do
{
x= select(a);
if feasible(solution ,x) then
solution=Union(solution ,x);
}
return solution;
}

21. Define optimal solution for Job sequencing with deadlines.


Ans:Feasible solution with maximum profit is optimal solution for Job sequencing with
deadlines.
22.Write the difference between the Greedy method and Dynamic programming.
Ans:Greedy method Dynamic programming
1. Only one sequence of decision is 1.Many number of decisions are
generated. generated.
2. It does not guarantee to give an 2.It definitely gives an optimal
optimal solution always. solution always.
23. Define dynamic programming.
Ans:Dynamic programming is an algorithm design method that can be used when a solution
to the problem is viewed as the result of sequence of decisions.

24.What are the features of dynamic programming?


Ans:Optimal solutions to sub problems are retained so as to avoid recomputing their values.
Decision sequences containing subsequences that are sub optimal are not considered. It
definitely gives the optimal solution always.
25.What are the drawbacks of dynamic programming?
Ans: Time and space requirements are high, since storage is needed for all
level. Optimality should be checked at all levels.
26.Write the general procedure of dynamic programming.
Ans:The development of dynamic programming algorithm can be broken
into a sequence of 4 steps.
1. Characterize the structure of an optimal solution.
2. Recursively define the value of the optimal solution.
3. Compute the value of an optimal solution in the bottom-up fashion.
4. Construct an optimal solution from the computed information.
27.Define principle of optimality.
Ans:It states that an optimal sequence of decisions has the property that whenever the initial
stage or decisions must constitute an optimal sequence with regard to stage resulting from the
first decision.

Long Answer type Questions

1) Explain the scheme to construct bi-connected graph?


2) Explain spanning trees and minimum cost spanning trees with suitable examples?
3) Prove that the greedy method produces an optimal solution to the job sequencing
problem?
4) Present greedy algorithm for sequencing unit time jobs with deadlines and profit?
5) Explain the general concept of dynamic programming?
6) Find the solution for the knapsack problem. when
n=3,(W1,W2,W3)=(18,15,10).(P1,P2,P3)=(25,24,15) AND M=20.
7) Explain traveling sales person problem?
8) Explain about optimal binary search tress?
9) Take an example problem and solve All-Pairs shortest path?
10) Explain and give an example for single source shortest path?
Unit 3
Objective Questions

1. In a binary tree, the number of terminal nodes (leaf nodes)are 10, then the
number of nodes with two children are

A)9 B)10 C)11 D)20


ANS:A

2. If the postorder and preorder traversal of a binary tree are M,N,L,P,R,O,K


and M,N,L,P,R,O,K respectively then, the inorder traversal of that tree is

A) M,L,N,K,P,O,R

B)L,N,M,K,P,R,O

C)P,R,O,K,L,N,M

D)M,N,O,P,R,L,K
ANS:A

3. Which of the following statement is true in case of a binary tree

A)There is no node with degree greater than two

B)The left or right subtree can not be empty

C)A node is said to be a leaf only if it contains one child

D)the level of any node is two more than the level of parent node
ANS:A

4. When comparing the binary tree with the general tree, which statement is true?

A)The binary tree as well as the general tree can be empty

B)The binary tree or the general tree can never be empty

C)The general tree, like the binary tree consists of left and right child

D)Binary tree consists of left and right child, whereas a general tree consists of
collection of sub trees.
ANS:D
5. If T(n,e) represents the maximum time taken by DFS for an n-vertex, e-edge
graph, then what is the value of T(n,e) if adjacency lists are used.

A)O(n+e) B)O(ne) C)O(n-e) D)O(2n )


ANS:A

6.If S(n,e) represents the maximum additional space taken by DFS for an n-vertex, e-
edge graph, then what is the value of S(n,e) if adjacency lists are used.
A)O(n) B)O(n+e) C)O(n-e) D)O(2n )
ANS:A

7.If T(n,e) represents the time complexity of DFS for an n-vertex, e-edge graph, then
what is the value of T(n,e) if adjacency matrix is used.

A)O(n+e)

B)O(ne)

C)O(1)

D)O(n2)
ANS:D

8.If adjacency matrix is used, then what is the time complexity of BFS algorithm?

A)O(n) B)O(e)

C)O(n2) D)O(n+e)
ANS:C

9.The broken edges of the depth first spanning tree of the graph are called _ _ _ _

A)light edges B)dark edges C)back edges D)invisible


edges

ANS:C

10.A graph G is biconnected if and only if _ _ _ _ _ _ _ _ _

A)it contains no articulation points

B)it contains no loops

C)it contains no cycle

D)it contains no parallel edges


ANS:A

11.Two biconnected components can have _ _ _ _ _ _ _ _

A)at most one vertex in common

B)at most two verticies in common

C)no common vertex at all


D)at most one edge in common
ANS:D

12.The common vertex of two biconnected components is called _ _ _ _ _ _ _ _ _ _ _


A)super node

B)dead node

C)Hi node

D)articulation point
ANS:D

13.Which statement is not true in case of backtracking Method ?

A)Many problems which deal with searching for a set of solutions can be
solved using the backtracking method.

B)Backtracking is a variation of the basic dynamic programming idea.

C)Using backtracking method, we can solve problems in an efficient way,


when compared to greedy method.

D)For a given solution space a unique tree organization is


possible.
ANS:D
14.Which statement is not true in case of backtracking Method ?

A)Implicit constraints describe the way in which the xi must relate to each
other.
B)Backtracking can not be used for N queens problem

C)Often the problem to be solved using backtrack method, calls for finding one
vector that maximizes or minimizes or satisfies a criterion function.

D)Explicit constraints are rules that restrict each xi to take on values only
from a given set.
ANS:B

15.In backtracking, _ _ _ _ _ _ _ _ _ _ _ are the rules that restrict each xi to take on


values only from a given set.

A)Explicit constraints B)implicit constraints

C)solution space D)criterion functions


ANS:A

16.In backtracking, _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ are the rules that determine which of


the tuples in the solution space of I satisfy the criterion function.

A)Explicit constraints B)implicit constraints C)bounding function D)permutation


tree
ANS:B

17.The name backtrack was first coined by _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


A)D.H.Lehmer B)J.D.Ullman C)K.Thompson
D)R.E.Bellman
ANS:A

18.In many applications of the backtrack method, the desired solution is


expressible as -

A)an n-tuple(x1, x2. ..xn)

B)a algebric equation

C)a matrix

D)a set of binary trees


ANS:A

19.In backtracking Method, modified criterion function is also known as _ _ _ _ _

A)bounding function B)solution space

C)Explicit constraints D)implicit constraints


ANS:A

20.In backtracking, the function which needs to be maximized or minimized for a


given problem is known as _ _ _ _ _ _ _ _ _ _ _ _ _ _

A)Criterion function B)Maxmin function

C)Backtracking function D)Leveling function


ANS:A

21.If we represent solution space in the form of a tree, then the tree is referred as_ _ _

A)BFS tree B)DFS tree

C)state space tree D). Min - cost spanning tree


ANS:C

22.In backtracking, the tree organization for the solution space is also known as __ _
_______

A)Binary tree B)AVL tree C)Permutation tree


D)Balanced tree
ANS:C

23.The solution space tree of 8 queens contain _ _ _ _ _ _ _ _ _ _ _

A)8 tuples B)8* 8 tuples C)tuples D)8 to the power


of 8 tuples
ANS:D
24.Each node in the tree organization defines _ _ _ _ _ _ _ _ _ _ _ _ _ _

A)solution space B)criterion function C)problem state D)explicit


condition
ANS:C

25.A node which has been generated and all of whose children have not yet
been generated is

A)live node B)dead node C)E-node D)X-node


ANS:A

26.The live node whose children are currently being generated is called _ _ _ _ _

A) live node B) dead node C) E-node D)X-node


ANS:C
27.What is the problem statement of N Queens problem ?

A)N Queens are to be placed on a 8 X 8 chess board

B)N Queens are to be placed on a large chess board

C)N Queens are to be placed on a N X N chess board

D)N Queens are to be placed on a N X N chess board so that no two queens


are on the same row, column or diagonal.
ANS:D

28.For N Queens problem, the time complexity is _ _ _ _ _ _ _ _ _

A)O (n) B)O (n) C)n D)O (log n)


ANS:D

29.In the sum of subsets problem, if n=4, (w1, w2 w3, w4) = (11, 13, 24, 7) and
m=31 then solutions are _ _ _ _ _ _ _ where 1 represents weight chosen 0 represents
weight is not choosen.

A)(1,1,0,1) and (0,0,1,1) B)(0,1,1,0) and (1,0,0,1)

C)(1,1,1,1) and (0,0,0,1) D)(1,0,0,0) and (1,0,1,0)


ANS:B

30.In sum of subsets problem, the implicit constraint is _ _ _ _ _ _ _ _ _ _

A)the sum of the corresponding weights must be m

B)the product of the corresponding weights must be m

C)the difference between any two weights must be m

D)the square root of the sum of the corresponding weights must be m


ANS:A

31.If n = 4 in the sum of subset problem, then the possible leafnodes in the tree
organization are _
A)4 B)8 C)20 D)16
ANS:D

32.From the given n distinct positive numbers, finding all combinations of these
numbers whose sums are m is called _ _ _ _ _ _ _ _ _ _

A)chromatic number problem

B)N queens problem

C)sum of subsets problem

D)mn combination problem


ANS:C

33.In the tree of fixed tuple size formulation, all paths from the root to a leaf node
define _ _ _ _ _ _ _ _ _ _ _ _ _ _

A)solution space

B)problem state

C)degree of bounding function

D)critical path
ANS:A

34.In the tree of fixed tuple size formulation, the nodes are numbered as in _ _ _

A)linear order

B)random order

C)D-search

D)BFS
ANS:C

35.Painting all the verticies of a graph with colors such that no two adjacent vertices
have the same color is called _ _ _ _ _ _ _ _ _ _ _ of the graph.

A)N- chromatic B)bichromatic C)coloring D)Hi-color


ANS:C
Fill in the Blanks

31. The running time of DFS is…….. Ɵ (V + E)

32. The total running time of BFS is…….. Ɵ (V + E)

33. The maximum number of comparisons required to search avai

using binary search with 16 elements is :->4

34. The maximum number of comparisons required to search an a

by using binary search with 64 elements is:->6

35. If elements are sorted then the following search is most suitable :-> binary search

36. The difference between merge sort and quick sort is :-> use of external array

37. According to pseudo code conventions elements of D array can be :-> s[4,5]

38. If a and b are positive integers the following arithmetic gives

Algorithm pqr(a,b)

ifb=0 then return 0;

else return a+pqr(a,b-l);

it

Algorithm pqr(a,b)

ifb=0 then return 0;

else return a+pqr(a,b-l);

} :->ax b

39. In knapsack problem optimal solution is obtained by using the following method :-
>selecting

items in the descending order of profits per weight.

40. If j is a node on the path item then set parent (i) <— roof (i) this rule is called as :->
collision rule

True or False

1. A graph G is binconnectcd if it contains no articulation point. T


2. The total time needed to process the n - 2 finds is O(n) F
3. The time required to process a FIND for an element at level i of a tree is……..:-> O(n) F
4. The Big Oh notation gives the limit the lowest maximum of the function T
5. In case of Ackeruann's function A (P1fV) if P=0 :->a q T
Two marks Questions

1.Define flow shop scheduling.


Ans:The processing of jobs requires the performance of several distinct job. In flow shop we
have n jobs each requiring n tasks i.e. T1i, T2i,…...Tmi, 1<i<n.
2.What are the conditions of flow shop scheduling?
Ans:Let Tji denote jth task of the ith job. Task Tij is to be performed on Pj number of
processors where 1<j<m i.e. number of processors will be equal to number of task Any task
Tji must be assigned to the processor Pj.
No processor can have more than one task assigned to it at any time. For any job I processing
the task for j>1 cannot be started until T(j-i),i has been
completed.
3.Define non-preemptive schedule.
Ans:A nonpreemptive schedule is a schedule in which the processing of a task on any
processor is not terminated until the task is complete.
4. Define preemptive schedule.
Ans:A preemptive schedule is a schedule in which the processing of a task on any processor
can be terminated before the task is completed.
5.Define finish time
Ans:The finish time fi (S) of job i is the time at which all tasks of job i have been completed
in schedule S.The finish time F(S) of schedule S is given by
F(S)=max{ fi (S)} 1<i<n
6.Define mean flow time
Ans: The mean flow time MFT (S) is defined to be]
Σfi(S)MFT (S) = 1 n 1<i<n
7.Define optimal finish time.
Ans:Optimal finish time scheduling for a given set of tasks is a nonpreemptive schedule S for
which F (S) is minimum over all nonpreemptive schedules S.
8.Define preemptive optimal finish time.
Ans:Preemptive optimal finish time scheduling for a given set of tasks is a preemptive
schedule S for which F (S) is minimum over all preemptive schedules S.
9. What are the requirements that are needed for performing Backtracking?
Ans:To solve any problem using backtracking, it requires that all the solutions satisfy a
complex set of constraints. They are:
i. Explicit constraints.
ii. Implicit constraints.
10.Define explicit constraint.
Ans:They are rules that restrict each xi to take on values only from a give set. They depend
on the particular instance I of the problem being solved. All tuples that satisfy the explicit
constraints define a possible solution space.

Long Answer type Questions

1) Write an algorithm to estimate the efficiency of backtracking?


2) Explain 4-queen problem using backtracking?
3) Explain spanning trees and minimum cost spanning trees with suitable example?
4) How many solutions are there to the eight queens problem? How many distinct
solutions are there if we do not distinguish solution that can be transformed into one
another by rotations and reflections?
5) Explain about graph coloring and Hamiltonian cycles with examples?
6) Explain about knapsack problem with example?
7) Explain about techniques for binary trees and techniques for graphs?
8) Explan about DFS?
Unit 4
Objective Questions

1. The term _ _ _ _ _ _ _ _ _ _ _ _ refers to all state space search methods in which all
children of the E-node are generated before any other live node can become the E-node

A)Branch-and-bound

B)modular arithmetic

C)inter polation

D)transformation
ANS:A

2. A search strategy that uses a cost function to select the next E-node would always choose
for its next E-node a live node with least _ _ _ _ _ _ _ _ _ _

A)FIFO function

B)LIFO function

C)cost function

D)branch function
ANS:C

3. A maximization problem is easily converted to a minimization problem __ _ _ _

A)by changing the sign of the objective function

B)by taking the reciprocal of the objective function

C)by taking the square root of the objective function

D)by taking the functional value of the objective function


ANS:A

4. _ _ _ _ _ _ is the column wise reduction sum of the cost matrix

A)4

B)8
C)12

D)16
ANS:A
5. _ _ _ _ _ _ is the cumutative reduction sum of the cost matrix

A)5 B)15 C)25 D)29


ANS:C

6. Depth first search is also called _ _ _ _ _ _ _ _ _ _ _

A)D-search

B)F-search

C)L-search

D)I-search
ANS:A

7. An optimal solution is a feasible solution with _ _ _ _ _ _ _ _ _ _

A)maximum value B)minimum value C)zero value D)infinite value


ANS:A

8. We start at a particular node in the graph, visiting all nodes exactly once and come back
to initial node with minimum cost. This is known as _ _ _ _ _ _ _

A) 0/1 knapsack problem B)optimal storage on tapes


C)minimum cost spanning tree D)traveling sales person problem
ANS:D
9. In finding the reduced cost matrix from a given cost matrix , we take minimum element
from first row ,then subtract that element from first row and take minimum element from
second row, then subtract that element from second row and so on. This is known as _ _ _
_____

A)row subtraction B)row manipulation C)row reduction D)row-cost


finding
ANS:C

10. In finding the reduced cost matrix from a given cost matrix , we take minimum
element from first column ,then subtract that element from first column and take
minimum element from second column , and then subtract that element from
second column and so on. This is known as _ _ _ _ _ _ _ _ _ _

A)column reduction B)column manipulation C)column subtraction


D)column hiding

ANS:A

11. _ _ _ _ _ _ _ _ _ _ _ _ is the row wise reduction sum of the cost matrix

A)7 B)14 C)21 D)28

ANS:C
12. If M=15, n=4, P1, P2, P3, P4=(10,10,12,18) and W1,W2, W3,W4=(2,4,6,9) of
0/1 knapsack problem then using LC branch-and-bound search, the upper
bound of node 1 is _ _ _ _ _

A)-32 B)-34 C)-36 D)-38

ANS:A

13. If M=15, n=4, =(10,10,12,18) and =(2,4,6,9) of 0/1 knapsack problem


then the maximum profit is _ _ _ _ _ _

A)32 B)34 C)36 D)38

ANS:D

14. In Job sequencing with deadlines problem, for any Job i the profit Pi is earned if and only
if _ _ _ _ _ _ _ _

A)the Job is completed by its deadline.

B)the Job is initiated before the deadline.

C)half of the Job is completed by its deadline.

D)75 % of the Job is completed by its deadline


ANS:A

15. _ _ _ _ _ _ is the cumulative reduction of the cost matrix

A)0
B)á

C)1

D)2
ANS:A

16. In branch and bound Method, the three common search strategies are __ _ _

A)FIFO, LIFO and LC

B)queue, stack and tree

C)array, linked list and stack

D)stack, queue and graph


ANS:A

17. _ _ _ _ _ _ _ _ is the time complexity for the traveling salesperson problem, if it


is solved by using LCBB.

A)O(n )

B)O( 2n)

C)O(n3 )

D)O(n2 2n)
ANS:D

18. In branch-and- bound terminology, a BFS like state space search will be called _ _ _
_ _ _ _ _ _ search.

A)linear B)random C)FIFO D)LIFO


ANS:C

19. The LC branch and bound search of a tree will begin with upper = _ _ _ _

A)1 B)2 C)0 D)infinite


ANS:C

20. The FIFO search coupled with bounding functions is called as _ _ _ _ _ _

A)FIFOBB B)least count search

C)cumulative reduction function D)column reduction


ANS:A

Fill in the Blanks

1. If four matrices A,B,C and D are given with orders 50Xl 0, IOX40,40X30 and 30X5
respectively
2. then the minimum number of multiplications required :->10,500
3. If four matrices A,B,C and D are given with orders 50Xl 0, IOX40,40X30 and 30X5
respectively
4. then the maximum number of multiplications required :->87,500
5. The number of orderings of product of 5 matrices is :-> 14
6. If four matrices A,B,C and D are given with orders 5X 4 4X3 3x2 and 2x5 respectively
then the
7. minimum number of multiplications required to get product ABCD :->114
8. If four matrices A,B,C and D are given with orders 5X 4 4X3 3x2 and 2x5 respectively
then the
9. maximum number of multiplications required to get product ABCD :->190
10. If four matrices A,B,C and D are given with or 50x10 10x40 40x30 30x5
respectively
11. then the number of orderings of product of matrices :->5

True or False
1. Heap is defined to be a complete binary tree. T
2. In a Max heap the largest key is at the root. T
3. The asymptotic complexity in terms of n is O(log n)? T
4. Heap sort is found to be very efficient with regard to storage requirement. T
5. For the improvement of efficiency of quick sort the pivot can be the mean element.T

Two marks Questions

Define state space tree.


Ans:The tree organization of the solution space is referred to as state space tree.
Define state space of the problem.
Ans:All the paths from the root of the organization tree to all the nodes is called as state space
of the problem
Define answer states.
Ans:Answer states are those solution states s for which the path from the root to s defines a
tuple that is a member of the set of solutions of the problem.
What are static trees?
Ans:The tree organizations that are independent of the problem instance being solved are
called as static tree.
What are dynamic trees?
Ans:The tree organizations those are independent of the problem instance being solved are
called as static tree.
Define a live node.
Ans:A node which has been generated and all of whose children have not yet been generated
is called as a live node.
Define a E – node.
Ans: E – node (or) node being expanded. Any live node whose children are
currently being generated is called as a E – node.
Define a dead node.
Ans:Dead node is defined as a generated node, which is to be expanded further all of whose
children have been generated.
What are the factors that influence the efficiency of the backtracking algorithm?
Ans:The efficiency of the backtracking algorithm depends on the following four factors.
They are:
The time needed to generate the next xk
The number of xk satisfying the explicit constraints.
The time for the bounding functions Bk
The number of xk satisfying the Bk.
Define Branch-and-Bound method.
Ans:The term Branch-and-Bound refers to all the state space methods in which all children of
the E-node are generated before any other live node can become the E- node.
What are the searching techniques that are commonly used in Branch-and-Bound method.
Ans:The searching techniques that are commonly used in Branch-and-Bound
Method are:
FIFO
LIFO
LC
Heuristic search
State 8 – Queens problem.
Ans:The problem is to place eight queens on a 8 x 8 chessboard so that no two queen “attack”
that is, so that no two of them are on the same row, column or on the diagonal.
State Sum of Subsets problem.
Ans:Given n distinct positive numbers usually called as weights , the problem calls for
finding all the combinations of these numbers whose sums are m.
State m – colorability decision problem.
Ans:Let G be a graph and m be a given positive integer. We want to discover whether the
nodes of G can be colored in such a way that no two adjacent nodes have the same color yet
only m colors are used.
Define chromatic number of the graph.
Ans:The m – colorability optimization problem asks for the smallest integer m for which the
graph G can be colored. This integer is referred to as the chromatic number of the graph.
Define a planar graph.
Ans:A graph is said to be planar iff it can be drawn in such a way that no two edges cross
each other.

Long Answer type Questions

1. Give the solution to the 8-queens problem using backtracking


2. Write an algorithm to determine the Hamiltonian cycle in a give graph using backtracking.
3. Explain how backtracking is used for solving n- queens problem. Show the state
space tree.
4. Describe the algorithm for Hamiltonian cycles and Determine the order of magnitude of
the worst-case computing time for the backtracking procedure that finds all Hamiltonian
cycles.
5. Write the backtracking algorithm for the sum of subsets problem using the state
space tree corresponding to m=35, w=(20,18,15,12,10,7,5)
6. Device backtracking algorithm to find all solutions to the n-queens problem and
represent the solution space in state space tree.
7. Relate Hamiltonian cycle with travelling sales person problem and also give the
backtracking solution vector that finds all Hamiltonian cycles for any directed or
undirected graph.
8. Draw the portion of state space tree generated by recursive backtracking algorithm
for sum of subsets problem with an example.
Unit 5
Objective Questions

1. How do we reduce P to Q ?

A)Transform instances of P to instances of Q in polynomial time so that the solutions to


Q provides the solutions to P

B)The solutions to Q is the solutions to P

C)complement the variables

D)inverse the variables


ANS:A

2. What does it mean if Q is NP-Hard ?

A)Every problem P & NP lep Q

B)Every problem NP & P gep Q

C)Every problem P & NP geP Q

D)Every problem NP& P leP Q


ANS:A

3. What does it mean if Q is NP-Complete ?

A)Q is NP- Hard and Q å NP

B)Q is nearly NP-Hard

C)Q is NonDeterministic Turing Machine

D)Q is Deterministic turing Machine


ANS:A

4. What is the relation between P and NP?

A)P? NP, but no one knows whether P= NP

B)P = NP

C)P > NP

D)P < NP
ANS:A

5. What, intuitively, does it mean if we can reduce problem P to problem Q ?

A)P is "no harder than" Q


B)P is equal to Q
C)P is less than Q
D)P is greater than Q

ANS:A

6. A problem is intractable if all algorithms to solve that problem are of at least _ _ _ _ _


_

A)logarithemic time complexity

B)exponential time complexity

C)polynomial-time complexity

D)linear time complexity

ANS:B

7. NP complete stands for _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

A)Natural polynomial time complete

B)Non polynomial time complete

C)N-power time complete

D)Nondeterministic Polynomial-time complete

ANS:D

8. 2n does not overtake until _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


A)n reaches 200 B)n reaches 150

C)n reaches 100 D)n reaches 59

ANS:D

9. What do you mean, when you say a problem is in P ?

A)A solution can be found in Polynomial time.

B)A solution can not be found in Polynomial time

C)A solution can be found in logarithmic time

D)A solution can not be found in logarithmic time


ANS:A

10. What do you mean, when you say a problem is in NP ?

A)A solution can be verified in Polynomial time.

B)A solution can not be verified in Polynomial time


C)A solution can be verified in logarithmic time

D)A solution can not be verified in logarithmic time


ANS:A

11. How do we usually prove that a problem R is NP-Complete ?

A)Show R å NP, and reduce a known NP-complete problem Q to R.

B)Show R å P, and reduce a known P-complete problem Q to R

C)Show either R å NP or R å P , and reduce a known NP-complete problem Q


to R
D)check R has got exponential time complexity or not
ANS:A

12. In _ _ _ _ _ _ _ _ _ _ _ _ _ _ algorithms, the result of ever operation is uniquely


defined

A)linear

B)non linear

C)deterministic

D)Nondeterministic
ANS:C

13. _ _ _ _ _ _ _ _ _ are the examples of NP-Complete problems?

A)K-clique, subset-sum, 0/1 knapsack, Hamiltonian path, Graph coloring

B)Linear Search, Binary Search

C)Merge Sort, Quick Sort

D) Heap Sort, AVL Tree


ANS:A

14. An Optimization problem is one which asks _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

A)"What is the optimal solution to problem X "

B)"What is the worst time complexity to the problem X "

C)"What is the average time complexity to the problem X "

D)"What is the best time complexity to the problem X "


ANS:A

15. What is a clique?

A)A clique is a subset of vertices fully connected to each other i.e., a complete
subgraph of G

B)A clique is a subgraph with exactly three verticies

C)A clique is a subgraph with exactly six verticies

D)A clique is a subgraph with exactly nine vericies


ANS:A

16. What is the clique Problem ?

A)To find out "How large is the maximum-size clique in a graph "

B)To find out "How many Nodes are there in the graph "

C)To find out "How many parallel edges are there in the graph "

D)To find out "How many loops are there in the graph "
ANS:A

17. The problem is intractable, it means _ _ _ _ _ _ _ _ _ _ _

A)as the input size n increases, we are unable to solve them in reasonable time

B)it is a decision problem

C)its time complexity is exponential

D)its time complexity is polynomial


ANS:A

18. What is nondeterministic computer?

A)A computer that can guess the right answer or solution.

B)A computer that can understand the human feelings

C)A computer that is blessed with common sense

D)A computer with common sense and IQ


ANS:A

19. Boolean Satisfiability Problem can be solved in Polynomial time by a _ _ _ _ _ _ _

A)deterministic turning machine

B)Nondeterministic turning machine

C)simple linear algorithm

D)complex algorithm
ANS:A
20. In _ _ _ _ _ _ _ _ _ _ algorithms, operations are allowed to choose any one of the
outcomes subject to the termination condition.

A)bubble

B)hyper

C)deterministic

D)Nondeterministic
ANS:D

21. In general, a positive integer k has a length of _ _ _ _ _ _ bits when


represented in binary

A)k+ 2 B)k+10 C)log k +1 D)log k +5


ANS:B

22. _ _ _ _ _ _ _ _ _ is the time complexity of the function choice(), success() & failure()

A)O (1)

B)O (n)

C)O (nlogn)

D)O(n2)
ANS:A

23. A nondeterministic algorithm terminates _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ if and


only if there exists no set of choices leading to a success signal

A)successfully B)unsuccessfully C)abruptly


D)with multiple results

ANS:B

24. Any problem for which the answer is either zero or one is called _ _ _ _ _

A)a decision problem

B)minimization problem

C)maximization problem

D)optimization problem
ANS:A

25. Any problem that involves the identification of either minimum or maximum value of
a given cost function is known as _ _ _ _ _ _ _ _ _ _ _ _ _ _ __ _ _
A)min problem B)max problem

C)decision problem D)optimization problem


ANS:D

26. The most famous unsolved problem in computer science is _ _ _ _ _ _ _ _

A)P > NP or P < NP


B)P = NP or P? NP
C)P + NP = log (P - NP) or not
D)P ?NP = log (P+NP) or not
ANS:B

27. Only _ _ _ _ _ _ _ _ _ can be NP-complete

A)linear problems

B)Non-linear problems

C)decision problems

D)hard problems
ANS:C

28. _ _ _ _ _ _ _ _ _ _ _ problems involve finding a grouping, ordering or


assignment of a discrete, finite set of objects that satisfies given conditions

A)Linear B)Non-Linear

C)Combinational D)Hyper
ANS:C

29. _ _ _ _ _ _ _ _ _ _ _ has a finite-state-control (its program), a two way infinite


tape( its memory) and a read-write head(its program counter)

A)CD-ROM
B)CD Writer
C)turning Machine
D)parallel computer
ANS:C

30. If the time complexity of the algorithm is O ( ) then _ _ _ _ _ _ _ _ _ _

A)it is not a natural problem


B)it is practically useful algorithm
C)it is a linear problem
D)it is a non-linear problem
ANS:A

31. All NP-Complete problems are _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


A)NP-Hard
B)P-Hard
C)P
D)NP
ANS:A

32. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ search will run the same steps every time if it is given the
same input.

A)Deterministic Search
B)Nondeterministic Search
C)TABU search
D)Huffman search
ANS:A

33. Given a set S of n nonnegative integers, _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


_ _ _ _ requires the division of S into two subsets such that the sums of
number in each subset are as close as possible.

A)Number Partitioning Problem


B)Number Set Problem
C)Number finding Problem
D)Number elimination Problem
ANS:A

Fill in the Blanks

1. The number of orderings of product of 4 matices:->5


2. The number of orderings of product of 3 matices:->2
3. The number of orderings of product of 2 matices:->1
4. The amortized time complexity perform insert, delete and search operations in splay trees
is O(logn)
5. For 1000 flips of an 1 coin, the probability of having a streak ofatleast 20 heads is :->< =
6. 1/1000
7. In amortized body following is used :-> averaged time of all the operations of a data
8. how many people must be there in room that there is 50% chance that two of them joined
in the same day of the year. :->24
9. Four coins are tossed. The expectation of the number of the heads is:->2

True or False

1. The running time of insertion sort is O(n^2) T


2. Two main measures for the efficiency of an algorithm are time and space T
3. The worst-case time complexity of Merge Sort is O(log n). T
4. The comparisons are required in insertion sort to sort a file if the file is already sorted is
N-1.T
5. The time complexity of linear search is O(n) T
6. The time complexity of binary search is O(lon n) T
Two marks Questions

1. What are NP- hard and Np-complete problems?


Ans:The problems whose solutions have computing times are bounded by polynomials of
small degree.
2. What is a decision problem?
Ans:Any problem for which the answer is either zero or one is called decision problem.
3. What is maxclique problem?
Ans:A maxclique problem is the optimization problem that has to determine the size of a
largest clique in Grapg G where clique is the maximal subgraph of a graph.
4. what is approximate solution?
Ans: A feasible solution with value close to the value of an optimal solution is called
approximate solution
5. Define class P?
6. Compare NP-hard and NP-completeness?
7. Define NP- hard problem

Long Answer type Questions

1. Explain how branch and bound technique is used to solve 0/1 knapsack
problem.
2. What are the differences between FIFO and LC branch and bound solutions?
3. Explain the principles of FIFO Branch- and-Bound.
4. Consider the travelling salesperson instance defined by the cost matrix.
5. Obtain the reduced cost matrix and the portion of the state space tree that will be
generated by LCBB.

6. How to search an answer node in branch and bound using Least Cost Search?
Explain.
7. Obtain reduced cost matrix for travelling sales person problem. Consider the
instance define by the cost matrix:

8. Write the branch and bound algorithm to generate minimum length tour for the
given cost adjacency matrix.

Вам также может понравиться