department of computer science and engineering...
TRANSCRIPT
M.AARTHI- AP/CSE Mahalakshmi Engineering College Page 1
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
QUESTION BANK
UNIT-V
SUB CODE: CS2251 DEPT: CSE
SUB NAME: DESIGN AND ANALYSIS OF ALGORITHMS SEM/YEAR: III/ II
PART – A (2 Marks)
1. What is an approximation algorithm? (AUC MAY 2005)
Approximation algorithms are algorithms used to find approximate solutions to
optimization problems. Approximation algorithms are often associated with NP-
hard problems; since it is unlikely that there can ever be efficient polynomial-time
exact algorithms solving NP-hard problems, one settles for polynomial-time sub-
optimal solutions.
Unlike heuristics, which usually only find reasonably good solutions reasonably
fast, one wants provable solution quality and provable run-time bounds. Ideally,
the approximation is optimal up to a small constant factor (for instance within 5%
of the optimal solution).
Approximation algorithms are increasingly being used for problems where exact
polynomial-time algorithms are known but are too expensive due to the input
size.
A typical example for an approximation algorithm is the one for vertex cover in
graphs: find an uncovered edge and add both endpoints to the vertex cover, until
none remain. It is clear that the resulting cover is at most twice as large as the
optimal one. This is a constant factor approximation algorithm with a factor of 2.
2. What is a Biconnected graph? (AUC MAY / DEC 2010)
A connected undirected graph G is said to be bioconnected if it remains
connected after removal of any one vertex and the edges that are incident upon
the vertex.
A bioconnected component of an undirected graph is a maximal bioconnected
subgraph, that is, a bioconnected subgraph not contained in any larger
bioconnected subgraph.
3. What is a FIFO branch-and-bound algorithm? (AUC MAY 2010)
As all live nodes are inserted in a queue, the nodes with Ĉ (x) > upper bound is
disturbed randomly in the queue and could be killed only when such live nodes
become E-nodes.
M.AARTHI- AP/CSE Mahalakshmi Engineering College Page 2
This strategy is denoted as FIFOBB.
4. What is minimal spanning tree? (AUC DEC 2005 /JUN 2010/NOV 2010)
A minimum spanning tree (MST) of an undirected graph G is a tree formed from
graph edges that connects all vertices of G at lowest cost.
A minimum spanning tree exists if and only if G is connected.
The number of edges in the minimum spanning tree is a tree because it is a
cyclic, it is spanning because it covers every vertex. and it is minimum because it
covers with minimum cost.
5. When is problem called to be NP-Hard? (AUC JUN 2010)
NP-Hard: A problem L is NP-hard if and only if satisfiability reduces to L
6. Define NP Hard and NP Completeness. (AUC NOV 2010)
NP-Hard: A problem L is NP-hard if and only if satisfiability reduces to L
NP-Complete: A problem L is NP- complete if and only if L is NP-hard and L ε NP.
7. Write any two applications of depth first search method. (AUC DEC 2010)
Finding connected and strongly connected components.
Topological sorting.
Solving puzzles with only one solution, such as mazes.
Maze generation may use a randomized depth-first search.
8. Define state space tree. (AUC DEC 2010)
The tree organization of solution space is termed as state space tree. Each node
in this tree is called a problem state.
All paths from the root to other nodes is called state space of the problem.
9. Define a strongly connected digraph and give the minimum in degree of all the nodes in
the graph. (AUC MAY 2011)
A directed graph is strongly connected if and only if, for each pair of vertices v and w,
there is a path from v to w. (i.e. strong connectivity means travelling the one-way street
in their correct direction from anywhere to anywhere)
10. Perform depth first and breadth first search on the following graph and find all the nodes
reachable from ‘a’. (AUC MAY 2011)
11. What is spanning tree? Give an example. (AUC MAY 2011)
A minimum spanning tree (MST) of an undirected graph G is a tree formed from
graph edges that connects all vertices of G at lowest cost.
A minimum spanning tree exists if and only if G is connected.
M.AARTHI- AP/CSE Mahalakshmi Engineering College Page 3
The number of edges in the minimum spanning tree is a tree because it is a
cyclic, it is spanning because it covers every vertex. and it is minimum because it
covers with minimum cost.
Examples:
12. What is NP Completeness? (AUC MAY 2011)
NP-Complete: A problem L is NP- complete if and only if L is NP-hard and L ε NP.
13. What is an articulation point in a graph? Give the condition to identify the articulation
point. Define Articulation point. (AUC MAY 2012/ DEC 2012)
A vertex v is an articulation point or cut point for an undirected graph G if there are
distinct vertices w and x, distinct from v also such that v is in every path from w to x.
The definition of articulation point (or) cut point can be once again defined using
simple terms. (i.e.) A vertex v in a connected graph G is an cut point if and only if the
deletion of vertex v together with all edges incident to v disconnects the graph into
two or more nonempty components.
14. What is the difference between BFS and DFS methods? (AUC MAY 2012)
S.No Depth first search Breadth first search
1 Backtracking is possible from a dead end Backtracking is not possible
2 Vertices from which exploration is incomplete
are processed in LIFO order
The vertices to be explored are
organized as a FIFO queue.
3 Search is done in one particular direction at
the time.
The vertices in the same level are
maintained parallelly. (left to right )
(alphabetical order)
4 Example:
Order of traversal:
A-> B-> C-> D-> E
Example:
Order of traversal:
A B C D E F G H
15. What is the property of NP-Complete problem? (AUC DEC 2012 / DEC 2013)
In computational complexity theory, the complexity class NP-Complete
(abbreviated NP-C or NPC) is a class of decision problems.
A decision problem L is NP-complete if it is in the set of NP problems and also in
the set of NP-hard problems.
16. Define Branch and Bound?
17. What is live node?
18. What are traceable and in traceable problems?
M.AARTHI- AP/CSE Mahalakshmi Engineering College Page 4
PART-B (16 Marks)
1. Explain in detail the Graph Traversals.(16) (AUC MAY 2010)
Explain the graph traversal algorithm and analyze the two algorithms in terms of their
time complexity.(16) (AUC JUN 2010)
M.AARTHI- AP/CSE Mahalakshmi Engineering College Page 5
M.AARTHI- AP/CSE Mahalakshmi Engineering College Page 6
M.AARTHI- AP/CSE Mahalakshmi Engineering College Page 7
2. With an example, explain how the branch-bound technique is used to solve 0/1
knapsack problem.(16) (AUC MAY 2010)
This is a maximization problem similar to be discussed under greedy method, but the difference is that fractions of object xi is not considered and an object is either included as a whole in the knapsack or excluded.
M.AARTHI- AP/CSE Mahalakshmi Engineering College Page 8
M.AARTHI- AP/CSE Mahalakshmi Engineering College Page 9
3. Explain the technique used to find MST with example. (8) (AUC JUN 2010)
4. What is the idea behind branch and bound technique? Explain how this technique is
applied for global optimization problems. (16) (AUC JUN 2010)
5. Explain with an algorithm as to how 0/1 knapsack problem is solved using branch and
bound technique. Apply branch and bound technique to solve the following 0/1
knapsack instance if W=10 (16) (AUC DEC 2010)
Items Weight Value
1 4 40
2 7 42
3 5 25
4 3 12
M.AARTHI- AP/CSE Mahalakshmi Engineering College Page 10
6. Write an algorithm and explain to determine Biconnected Components. Prove the
theorem that two Biconnected components can have at most one vertex as common
and this vertex is an articulation point. (16) (AUC DEC 2010)
Discuss in detail about the Biconnected components of a graph.(16) (AUC MAY 2012)
M.AARTHI- AP/CSE Mahalakshmi Engineering College Page 11
With an example explain the algorithm to determine Biconnected components in the
graph. (AUC DEC 2010)
M.AARTHI- AP/CSE Mahalakshmi Engineering College Page 12
M.AARTHI- AP/CSE Mahalakshmi Engineering College Page 13
M.AARTHI- AP/CSE Mahalakshmi Engineering College Page 14
M.AARTHI- AP/CSE Mahalakshmi Engineering College Page 15
M.AARTHI- AP/CSE Mahalakshmi Engineering College Page 16
M.AARTHI- AP/CSE Mahalakshmi Engineering College Page 17
M.AARTHI- AP/CSE Mahalakshmi Engineering College Page 18
M.AARTHI- AP/CSE Mahalakshmi Engineering College Page 19
12. Write the Kruskal’s algorithms apply it to find a minimum spanning tree for the
following graph. (16) (AUC MAY 2011)
M.AARTHI- AP/CSE Mahalakshmi Engineering College Page 20
M.AARTHI- AP/CSE Mahalakshmi Engineering College Page 21
M.AARTHI- AP/CSE Mahalakshmi Engineering College Page 22
13. Write short notes on NP-hard and NP-completeness.(16) (AUC MAY 2011)
M.AARTHI- AP/CSE Mahalakshmi Engineering College Page 23
Relationship between NP-Hard and NP-Complete.
M.AARTHI- AP/CSE Mahalakshmi Engineering College Page 24
M.AARTHI- AP/CSE Mahalakshmi Engineering College Page 25
P class Problems Vs NP class problems:
S.No P Class NP Class
1 P class problems are solvable in
polynomial time.
NP class problems are hard or very time
consuming.
2 Deterministic algorithms are used –
Traceable.
Non deterministic algorithms are used-
Intractable.
3 Example: searching and sorting.
O( n log n), O(n).
Example: TSP and knapsack algorithm.
14. Write a complete LC branch-and-bound algorithm for the job sequencing with deadlines
Problem. Use the fixed tuple size formulation. (16) (AUC DEC 2011)
Least Cost (LC) search:
Both BFS and DFS blindly generates all live nodes, irrespective of whether they
lead to answer nodes or not hence one opt for a third strategy called LC search
which gives preference to nodes that lead to answer states quickly by making
M.AARTHI- AP/CSE Mahalakshmi Engineering College Page 26
use of an intelligent ranking function ĉ(.), for live nodes, which assigns better
rank to a node that leads to the answer state quickly than other nodes.
For any node x, the cost is defined by c(x) could be evaluated based on either (i)
the no of nodes in the sub tree x to reach the answer node or (i) the no of levels
to the sub tree from root x to reach answer node.
M.AARTHI- AP/CSE Mahalakshmi Engineering College Page 27
M.AARTHI- AP/CSE Mahalakshmi Engineering College Page 28
M.AARTHI- AP/CSE Mahalakshmi Engineering College Page 29
15. Write a non-deterministic algorithm to find whether a given graph contains a Hamiltonian
cycle.(16) (AUC DEC 2011)
M.AARTHI- AP/CSE Mahalakshmi Engineering College Page 30
16. Compare and contrast FIFO and LC branch – and – bound search techniques(16)
(AUC MAY 2012)
M.AARTHI- AP/CSE Mahalakshmi Engineering College Page 31
M.AARTHI- AP/CSE Mahalakshmi Engineering College Page 32
M.AARTHI- AP/CSE Mahalakshmi Engineering College Page 33
M.AARTHI- AP/CSE Mahalakshmi Engineering College Page 34
17. Write an algorithm for finding min-cost binary search tree What’s its time complexity?
(AUC DEC 2010)
M.AARTHI- AP/CSE Mahalakshmi Engineering College Page 35
M.AARTHI- AP/CSE Mahalakshmi Engineering College Page 36