You are on page 1of 10

CS8451- DESIGN AND ANALYSIS OF ALGORITHMS IV Semester CSE

DHANALAKSHMI COLLEGE OF ENGINEERING


Tambaram, Chennai

Department of Computer Science and Engineering

CS8451 – Design and Analysis of Algorithms


Year / Sem : II / IV
2 Marks Q & A

UNIT- V

Department of Computer Science and Engineering Page 1


CS8451- DESIGN AND ANALYSIS OF ALGORITHMS IV Semester CSE

UNIT- 5
COPING WITH THE LIMITATIONS OF ALGORITHM POWER

PART - A
1. Define  Hamiltonian circuit problem [A/M15]
Hamiltonian circuit problem is defined as the problem of finding a Hamiltonian circuit.
Hamiltonian circuit is a circuit that visits every vertex exactly once and returns to the starting
vertex.

2. What are tractable and non-tractable problems? [M/J18]


Tractable Problem: Problems that can be solved in polynomial time.
E.g.searching a key
Non-Tractable Problem: Problems that cannot be solved in polynomial time.
E.g. Knapsack problem

3. Define  P and NP problem [A/M17]


Polynomial Problem is defined as the problemwhich solves the problem in polynomial time.
An algorithm is called polynomial time algorithm (P-class) which solves the problem in
polynomial time. E.g. Search a key
Non-Deterministic Problem is defined as the problem which solves the problem in non-
deterministic polynomial time. E.g. Traveling Salesman Problem

4. Define TheBasic Principle of Backtracking[M/J12]


The basic principle of backtracking is defined as the desired solution expressed as n tuple
(x1,x2,…..xn) which is chosen from solution space, using backtrack formulation.
The solution obtained i.e (x1,x2,…..xn) can either maximizes or minimizes and satisfies the
criteria function.

5. What is sum of subset problem? [M/J13]


The sum of subset problem is used to find the subset of integers whose sum equal to W, where
W is a given positive integer.

6.Give the purpose of lower bound. [M/J16]


The purpose of lower bound is to estimate the minimum amount of work needed to solve the
problem.

7. List the applications of backtracking technique.


The applications of backtracking technique are:
a) N-Queens problem
b) Subset sum problem
c) Hamiltonian circuit problem

8. What are promising and non-promising nodes?


Promising node is a node in state space tree, if it corresponds to a partially constructed solution
that may still lead to complete solution. Otherwise the node is called non-promising node.

Department of Computer Science and Engineering Page 2


CS8451- DESIGN AND ANALYSIS OF ALGORITHMS IV Semester CSE

9. What is meant by mathematical modeling?


Mathematical modeling is a method of expressing the problem in terms of purely
mathematical objects such as variables, functions and equations.

10. What is meant by decision tree?


Decision trees are hierarchical structure representation model with internal nodes to represent
condition and leaf nodes for decision.

11. What is meant by live node?


A node that has been generated already but is yet to generate the children is called a live
node.

12. What is meant by optimization problem?


An optimization problem is a problem that identifies an optimal value (either maximum or
minimum value) of a given cost function.

13. What is meant by E-node?


A node that is under consideration and is in the process of being generated is called an
e-node.

14. What is meant by dead node?


A node that is already explained and cannot be considered for further searches is called a
dead node.

15. What is meant by branch and bound?


Branch and bound is a technique in which all children of the e-node are generated before any
other live node becomes e-node.

16. What are least cost and LC search?


The cost that minimizes the rank function is called least cost. A search that uses a cost
minimization technique is called Least Cost(LC) search.

17. List the methods for finding lower bounds.


The methods for finding lower bounds are:
a) Trivial lower bound
b) Information theoretic arguments
c) Reduction argument

18. What is meant by CNF form?


An expression is in conjunctive normal form (CNF) if the set of clauses are separated by an
AND operator and literals are connected by an OR operator.

19. What are the disadvantages of approximation algorithms?


The disadvantages of approximation algorithms are:
a) Approximation algorithms are limited to only a certain set of problems and not applicable
to decision problems.
b) It focuses only on the worst-case measures.

Department of Computer Science and Engineering Page 3


CS8451- DESIGN AND ANALYSIS OF ALGORITHMS IV Semester CSE

20. What are the advantages of approximation algorithms?


The advantages of approximation algorithms are:
a) It optimizes computer resources such as space and time.
b) It helps to categorize problems based on their difficulty levels.
c) These are valuable tools for developing and evaluating different types of heuristics for a
given problem.

21. What are called exact algorithms?


Exact algorithms are exponential algorithms that provide exact solutions for the given
problem.

22. What are called randomized algorithms?


Randomized algorithms use randomized decisions to guide decision making in the problem
solving methods. These algorithms are also known as probabilistic algorithms.

PART – B
1. State the subset-sum problem and Complete state-space tree of the backtracking
algorithm applied to the instance A={3, 5, 6, 7} and d=15 of the subset-sum problem.
[M-16]
 The subset-sum problem finds a subset of a given set A = {a1. . . an} of n positive
Integers whose sum is equal to a given positive integer d.
 For example, for A = {1, 2, 5, 6, 8} and d = 9, there are two solutions: {1, 2, 6} and {1,
8}. Of course, some instances of this problem may have no solutions.
 It is convenient to sort the set‘s elements in increasing order. So, we will assume that
a1< a2 < . . . < an.
 A = {3, 5, 6, 7} and d = 15 of the subset-sum problem. The number inside a node is the
sum of the elements already included in the subsets represented by the node. The
inequality below a leaf indicates the reason for its termination.

FIGURE Complete state-space tree of the backtracking algorithm applied to the instance

Department of Computer Science and Engineering Page 4


CS8451- DESIGN AND ANALYSIS OF ALGORITHMS IV Semester CSE

 The state-space tree can be constructed as a binary tree like that in the instance A = {3, 5, 6,
7} and d = 15.

 The root of the tree represents the starting point, with no decisions about the given elements
made as yet.

 Its left and right children represent, respectively, inclusion and exclusion of a1 in a set being
sought. Similarly, going to the left from a node of the first level corresponds to inclusion of a2
while going to the right corresponds to its exclusion, and so on.

 Thus, a path from the root to a node on the ith level of the tree indicates which of the first I
numbers have been included in the subsets represented by that node. We record the value of s,
the sum of these numbers, in the node.

 If s is equal to d, we have a solution to the problem. We can either report this result and stop
or, if all the solutions need to be found, continue by backtracking to the node‘s parent.

 If s is not equal to d, we can terminate the node as non-promising if either of the following
two inequalities holds:

𝑠 + 𝑎i+1 > 𝑑 [the sum s is too large],


s + 𝑎 𝑛𝑗 =𝑖+1 j < d [the sum s is too small].

2. What is an approximation algorithm? Give example.[N-13][M-15][N-15]


A polynomial-time approximation algorithm is said to be a approximation algorithm, where c ≥
1, if the accuracy ratio of the approximation it produces does not exceed c for any instance of the
problem in question: r(sa) ≤ c.

KNAPSACK PROBLEM
The knapsack problem, given n items of known weights w1, . . . , wn and values v1, . . . , vn and
a knapsack of weight capacity W, find the most valuable subset of the items that fits into the
knapsack.

Department of Computer Science and Engineering Page 5


CS8451- DESIGN AND ANALYSIS OF ALGORITHMS IV Semester CSE

3. Explain Traveling salesman problem by using branch and bound technique.


[N-13][M-15][N-15]

TRAVELING SALESMAN PROBLEM


Greedy Algorithms for the TSP
The simplest approximation algorithms for the traveling salesman problem are based on the
greedy technique..
Nearest-neighbor algorithm
The following well-known greedy algorithm is based on the nearest-neighbor heuristic:
always go next to the nearest unvisited city.
Step 1 Choose an arbitrary city as the start.
Step 2 Repeat the following operation until all the cities have been visited:go to the
unvisited city nearest the one visited last (ties can be broken arbitrarily).
Department of Computer Science and Engineering Page 6
CS8451- DESIGN AND ANALYSIS OF ALGORITHMS IV Semester CSE

Step 3 Return to the starting city.


For Example,

4. Briefly explain NP-Hard and NP-Completeness with example. [M-14] [M-15] [N-15]

Class P: An algorithm solves a problem in polynomial time if its worst-case time efficiency
belongs to O(p(n)) where p(n) is a polynomial of the problem‘s input size n.
Problems that can be solved in polynomial time are called tractable, and problems that cannot be
solved in polynomial time are called intractable.
 Class P is a class of decision problems that can be solved in polynomial time by
(deterministic) algorithms. This class of problems is called polynomial. (Class P)
 Examples: Searching, Element uniqueness, primality test, graph acyclicity

Class NP: A nondeterministic algorithm is a two-stage procedure that takes as its input an
instance I of a decision problem and does the following.
Nondeterministic (―guessing‖) stage:
An arbitrary string S is generated that can be thought of as a candidate solution to the given instance I
(but may be complete gibberish as well).
· Class NP is the class of decision problems that can be solved by nondeterministic polynomial
algorithms. This class of problems is called nondeterministic polynomial.
· Examples: TSP, AP, Graph coloring problem, partition problem, Hamiltonian circuit problem

Class- NP Complete: A decision problem D1 is said to be polynomially reducible to a


decision problem D2, if there exists a function t that transforms instances of D1 to instances
of D2 such that:
1. t maps all yes instances of D1 to yes instances of D2 and all no instances of D1 to no
instances of D2

Department of Computer Science and Engineering Page 7


CS8451- DESIGN AND ANALYSIS OF ALGORITHMS IV Semester CSE

2. t is computable by a polynomial time algorithm


A decision problem D is said to be NP-complete if:
1. it belongs to class NP
2. every problem in NP is polynomially reducible to D

5.Explain 8 Queens problem with example. [M-14][N-13] [N-14]

The n-queens problem is to place n queens on an n × n chessboard so that no two queens attack each
other by being in the same row or in the same column or on the same diagonal.

Department of Computer Science and Engineering Page 8


CS8451- DESIGN AND ANALYSIS OF ALGORITHMS IV Semester CSE

Department of Computer Science and Engineering Page 9


CS8451- DESIGN AND ANALYSIS OF ALGORITHMS IV Semester CSE

Department of Computer Science and Engineering Page 10

You might also like