0% found this document useful (0 votes)
32 views11 pages

Daa QB Short

This document contains a question bank with multiple choice questions and answers related to the topics of algorithms design and analysis. The questions cover key concepts like defining algorithms, analyzing time and space complexity, order of growth, divide and conquer methods, sorting algorithms like quicksort and mergesort, graph algorithms like minimum spanning trees and disjoint sets. The answers provide detailed explanations of the concepts in the questions.
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)
32 views11 pages

Daa QB Short

This document contains a question bank with multiple choice questions and answers related to the topics of algorithms design and analysis. The questions cover key concepts like defining algorithms, analyzing time and space complexity, order of growth, divide and conquer methods, sorting algorithms like quicksort and mergesort, graph algorithms like minimum spanning trees and disjoint sets. The answers provide detailed explanations of the concepts in the questions.
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/ 11

DESIGN AND ANALYSIS OF ALGORITHMS

Question Bank Two Mark Question and Answers


UNIT-I
1 Define an algorithm
2 List the two major phases of performance evaluation.
3 What do you mean by space and time complexity?
4 What is the difference between profiling and debugging?
5 Define order of growth
6 What is the difference between little o and big O?
7 What is the use of divide and conquer method?
8 What is the time and space complexity of quick sort?
9 What is the recurrence relation of merge sort?
10 Give the formula for Strassen’s matrix multiplication

Answers
1. Define an algorithm.
Ans: An algorithm is a finite set of instructions which, if followed, accomplish a particular task.
2. List the two major phases of performance evaluation.
Ans: The two major phases of performance evaluation are: i) Time complexity and ii) Space complexity.
3. What do you mean by space and time complexity?
Ans:
i) Space Complexity: The Space complexity of an algorithm is the amount of memory it needs to run
to its completion.
ii) Time Complexity: The time complexity of an algorithm is the amount of computer time it needs to
run to its completion.
4. What is the difference between profiling and debugging?
Ans:
Profiling: Profiling or Performance measurement is the process of executing a correct program on
data sets and measuring the time and space it takes to compute the results.
Debugging: Debugging is the process of executing programs on sample data sets to determine whether
faulty results occur and if so, to correct them.
5. Define order of growth.
Ans:
 An order of growth is a set of functions whose asymptotic growth behaviour is considered equivalent.
For example, 2n, 100n and n + 1 belong to the same order of growth, which is written O(n) in Big-Oh
notation and often called linear because every function in the set grows linearly with n.

1|Pa ge
6. What is the difference between little o and big O?
Ans:
Little oh notation (o) :
 The function f(n) = o(g(n)) if and only if for all n, n ≥ 0 .
Big Oh notation (O) :
 The function f(n) = O(g(n)) [read as "f of n is big-oh of g of n"] if and only if there exist
positive constant c and n0 such that f ( n )  c * g(n) for all n, n  n0 .
7. What is the use of divide and conquer method?
Ans: Divide and Conquer:
 Given a problem, relatively large, divide-and-conquer strategy suggests splitting or dividing the
problem into sub-problems, solving the sub problems and then combining the sub-solutions to get
solution to the main problem.
 If the subproblems are still relatively large, then the divide-and conquer strategy can possibly be
reapplied.
8. What is the time and space complexity of quick sort?
Ans: The time complexity of Quick sort is

 The Space complexity of Quick sort is O(log n).


9. What is the recurrence relation of merge sort?
Ans:

10. Give the formula for Strassen’s matrix multiplication.


Ans: The recurrence formula for Strassen’s matrix multiplication is given by:

2|Pa ge
UNIT-II
1 What is set? What is disjoint set?
2 What are the operations cane be performed on set?
3 How to represent the disjoint sets?
4 Write simple union and find algorithms
5 Define weighting rule
6 Define E-node and Live node.
7 Differentiate the Dead node and Live node
8 What is a chromatic number?
9 List the applications of disjoint set
10 What is the need of collapsing find?

Answers
1. What is set? What is disjoint set?
Ans: Set: Sets are represented as a collection of well-defined objects or elements.
Disjoint Set: If Si and Sj, i ≠ j, are two sets, then there is no element that is in both Si and Sj.
2. What are the operations can be performed on set?
Ans: Set Operations:
 Disjoint Set Union and Find
3. How to represent the disjoint sets?
Ans:
Disjoint Set: If Si and Sj, i ≠ j are two sets, then there is no element that is in both Si and Sj.
Example: Let n = 10 elements can be partitioned into three disjoint sets as follows:
S1 = { 1, 7, 8, 9 }, S2 = { 2, 5, 10 } and S3 = { 3, 4, 6 }.
The Tree Representations for these disjoints are:

4. Write simple union and find algorithms.


Ans:

Algorithm:

3|Pa ge
5. Define weighting rule.
Ans:
Weighting Rule:
 If the number of nodes in tree with root “i” is less than the number of nodes in tree root “j”, then
make j the parent of i, otherwise make i the parent of j.
6. Define E-node and Live node.
Ans:
E-node: The live node whose children are currently being generated is called the E-node (node being
expanded).
Live node: Live node is a node that has been generated but whose children have not yet been generated.

7. Differentiate the Dead node and Live node.


Ans:
Dead node: It is generated node that is either not to be expanded further or one for which all of its children
have been generated.
Live node: Live node is a node that has been generated but whose children have not yet been generated.

8. What is a chromatic number?


Ans:
Chromatic Number:
 The minimum number of colors required to color a graph is called chromatic number and the
chromatic number is represented by (G).
9. List the applications of disjoint set.
Ans: Applications of Disjoint Set:
1) It is used to keep track of connected components in an undirected graph.
2) It is used to detect cycles in the graph.
3) It is used to calculate the minimum spanning tree in Kruskal's algorithm.
4) It is used in Maze generation problems.
5) Calculating mutual friends.

10. What is the need of collapsing find?


Ans: Collapsing Rule for Find:
 If ‘j’ is a node on the path from ‘i’ to its root and p[i] ≠ root[i], then set p[j] to root[i].
 Collapsing find algorithm is used to perform find operation on the tree created by WeightedUnion.

4|Pa ge
UNIT-III
1 What is the use of dynamic programming?
2 State the principle of optimality.
3 Define dominance rule
4 Define purging rule
5 List the applications of dynamic programming
6 State reliability system
7 What do you mean by optimal solution?
8 What is optimal binary search tree?
9 What is the difference between all pairs shortest path and single source shortest path?
10 How dynamic programming is different from greedy method?

Answers
1. What is the use of dynamic programming?
Ans: Dynamic Programming:
 Dynamic programming is an algorithmic design method that can be used when the solution to a
problem can be viewed as the result of a sequence of decisions.

2. State the principle of optimality.


Ans: Principle of optimality:
 It states that an optimal sequence of decisions has the property that whenever the initial state or
decisions are, the remaining decisions must constitute an optimal sequence with regard to state
resulting from the first decision.

3. Define dominance rule.


Ans: Dominance Rule:

4. Define purging rule.


Ans: Same as Q 3. Answer.
5|Pa ge
5. List the applications of dynamic programming.
Ans: Applications of Dynamic Programming:
1. All – pairs shortest path problem : O (n3)
2. Optimal binary search trees (OBST) : O (n3)
3. 0/1 knapsack or dynamic knapsack problem. : O (2n/2)
4. Reliability design : O (2n/2)
5. Traveling salesperson problem. : O (n2 2n)
[Time complexities are optional here, not compulsory]

6. State reliability system.


Ans: Reliability System:
 The problem is to design a system such that, each device in the system must work properly.
 The probability that the devices in the system will work / function properly is known as Reliability
System.
7. What do you mean by optimal solution?
Ans: Optimal Solution:
 A feasible solution that either maximizes or minimizes the given objective function is called optimal
solution.
8. What is optimal binary search tree?
Ans: Optimal Binary Search Tree(OBST):
 Optimal Binary Search Tree is a binary search tree which provides the smallest possible search
time (or expected search time) for a given sequence of accesses (or access probabilities).

9. What is the difference between all pairs shortest path and single source shortest path?
Ans: The single-source shortest-path problem requires that we find the shortest path from a single vertex to
all other vertices in a graph, whereas the all-pairs shortest-path problem requires that we find the shortest
path between all pairs of vertices in a graph.

10. How dynamic programming is different from greedy method?

Greedy Method Dynamic Programming

A single sequence of the decision is


Multiple of sequences of the decision are generated.
generated.

Not as reliable as Dynamic programming. very reliable.

More efficient as compared to a greedy


Less efficient as compared to a greedy approach
approach

An optimal solution may not be achieved. The optimal solution is achieved every time.

6|Pa ge
UNIT-IV
1 What is feasible solution?
2 What is greedy method?
3 What is cost adjacency matrix?
4 What is spanning tree?
5 Define 0/1 knapsack problem in view of greedy method
6 What do you mean by minimum cost spanning tree?
7 List the differences between tree and graph.
8 How to find the number of spanning tree possible from graph?
9 What is the improved time complexity of Prims algorithm?
10 What is the improved time complexity of Kruskal algorithm?

Answers
1. What is feasible solution?
Ans: Feasible Solution:
 Problems with n-inputs require us to obtain a subset that satisfies some constraints.
 Any subset that satisfies these constraints is called a “Feasible solution”.
2. What is greedy method?
Ans: Greedy Method:
 The Greedy Method is a technique that is used to find an optimal solution to a given problem
from a set of feasible solutions.
3. What is cost adjacency matrix?
Ans: Cost-adjacency (or) Distance Matrix:
 The representation of a graph (or weighted graph) in the form of a matrix is known as Cost-
adjacency matrix.
4. What is spanning tree?
Ans: Spanning Tree:
 Let G=(V,E) be an undirected connected graph.
 A subgraph t=(V, E’) of G is said to be a spanning tree iff
i) t must be a tree and
ii) t contains all the vertices of G.
5. Define 0/1 knapsack problem in view of greedy method.
Ans: Greedy Knapsack Problem:
 Given n – objects and a knapsack.
 Each object has weight wi and knapsack has a capacity m, we need to fill the knapsack such that
maximum profit is earned with total weight  m.

7|Pa ge
6. What do you mean by minimum cost spanning tree?
Ans: Minimum Cost Spanning Tree:
 The minimum – cost spanning tree is a spanning tree with the total weights on the edges is at
minimum.
7. List the differences between tree and graph.
Ans:

No. Graph Tree

1 It is a non-linear data structure. It is also a non-linear data structure.

2 A graph is a set of vertices/nodes and edges. A tree is a set of nodes and edges.

In the graph, there is no unique node which is In a tree, there is a unique node which is
3
known as root. known as root.

4 Graphs can form cycles. Trees cannot form a cycle.

8. How to find the number of spanning tree possible from graph?

Ans: If the graph consists of n-vertices then the possible no. of spanning trees are: nn-2.

9. What is the improved time complexity of Prims algorithm?


Ans: The improved time complexity of the prim's algorithm is O(E logV) or O(V logV) or O(n logn), where
E is the no. of edges, and V is the no. of vertices.

10. What is the improved time complexity of Kruskal algorithm?


Ans: The improved time complexity of the Kruskal 's algorithm is O(E logV), where E is the no. of edges,
and V is the no. of vertices.

8|Pa ge
UNIT-V
1 What is the use of branch and bound technique?
2 Define bounding function.
3 List the two types of search methods in branch and bound
4 What is the constraint used to expand the node in FIFOBB?
5 What is row and column reduction?
6 Define intelligent function or ranking function?
7 What is the relation between NP-hard and NP-complete?
8 Define NP problem
9 What is halting problem?
10 What is Clique problem?
Answers
1. What is the use of branch and bound technique?
Ans: Branch and Bound Technique:
 Branch and bound is an algorithm design paradigm which is generally used for
solving combinatorial optimization problems. These problems are typically
exponential in terms of time complexity and may require exploring all possible
permutations in worst case.
 The term Branch and Bound refers to all state-space search methods in which all
children of E-node are generated before any other live node become the E-node.
-------------------------------------------------------------------------------------------------------------
2. Define bounding function.
Ans: Bounding Function:
 A Bounding function is used to kill live nodes to make them dead nodes.
-------------------------------------------------------------------------------------------------------------
3. List the two types of search methods in branch and bound.
Ans: Types of search methods in Branch & Bound:
1. FIFO Branch and Bound (FIFOBB)
2. Least-Cost(LC) Branch and Bound (LCBB).
-------------------------------------------------------------------------------------------------------------
4. What is the constraint used to expand the node in FIFOBB?
Ans: To expand a node in FIFOBB, the constraint is that,

9|Pa ge
- “if the Lower bound of a node is greater than the global upper bound then kill the
node, otherwise expand the node”.
-------------------------------------------------------------------------------------------------------------
5. What is row and column reduction?
Ans: A row or column is said to be reduced iff it contains at least one zero & remaining
entries are non-negative.
 Row Reduction – Take minimum value in each and every row and subtract with
all other values in that row.
 Column Reduction – Take minimum value in each and every column and subtract
with all other values in that column.
[ See the example from sendil sir’s notes for clarification; filename: Unit 5 Branch and
Bound Traveling Salesman].
-------------------------------------------------------------------------------------------------------------
6. Define intelligent function or ranking function.
Ans:
 The search for an answer node can be obtained by using an “intelligent” ranking
function ĉ(.) for live nodes.

 The next E-node is selected on the basis of this ranking function.


 The node x is assigned a rank using: ĉ(x) = f(h(x)) + g(x)
where,

- ĉ(x) is the cost of x.


- h(x) is the cost of reaching x from the root and f(.) is any non-decreasing function.
- g(x) is an estimated cost needed to reach an answer node from x.
---------------------------------------------------------------------------------------------------------------
7. What is the relation between NP-hard and NP-complete?
Ans:
NP Complete Problem: A problem that is NP-Complete can solved in polynomial time if and
only if (iff) all other NP-Complete problems can also be solved in polynomial time.
NP-Hard: Problem can be solved in polynomial time then all NP-Complete problems can be
solved in polynomial time.
 All NP-Complete problems are NP-Hard but some NP-Hard problems are not know to be
NP-Complete.
10 | P a g e
8. Define NP problem.
Ans: NP Problem:
 It stands for Non-deterministic polynomial.
 The problems which can be solved by non-deterministic polynomial time are called
NP- problems.
------------------------------------------------------------------------------------------------------------
9. What is halting problem?
Ans: Halting Problem:
 The halting problem is to determine for an arbitrary deterministic algorithm A and
an input I, whether the algorithm A with input I ever halts/terminates.
[In simple sentence, determining whether a deterministic algorithm with some input
is halting or not].
-------------------------------------------------------------------------------------------------------
10. What is Clique problem?
Ans: Clique Problem:
 A clique is a subgraph of a graph such that all the vertices in this subgraph are
connected with each other, that is, the subgraph is a complete graph.
 The size of clique is the no. of vertices present in the graph.

------------------------------------------------------------------------------------------------------------------------------------------------
THE END

11 | P a g e

You might also like