Daa QB Short
Daa QB Short
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
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:
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.
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.
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.
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:
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.
Ans: If the graph consists of n-vertices then the possible no. of spanning trees are: nn-2.
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 END
11 | P a g e