Sie sind auf Seite 1von 4

1.

Define dynamic programming


 Dynamic programming is both a mathematical optimization method and a
computer programming method. The problem can be solved optimally by
breaking it into sub-problems and then recursively finding the optimal solutions to
the sub-problems, then it is said to have optimal substructure.

2. Explain the term “principle of optimality”

 A problem is said to satisfy the Principle of Optimality if the subsolutions of an


optimal solution of the problem are themesleves optimal solutions for their
subproblems.

 Examples:

o The shortest path problem satisfies the Principle of Optimality.

o This is because if a,x1,x2,...,xn,b is a shortest path from node a to node b


in a graph, then the portion of xi to xj on that path is a shortest path from xi
to xj

3. Define Knapsack problem


 Given weights and values of n items, put these items in a knapsack of capacity
W to get the maximum total value in the knapsack
 In other words, given two integer arrays val[0..n-1] and wt[0..n-1] which represent
values and weights associated with n items respectively

4. Apply backtracking technique and give one solution for 4-Queen problem

5. Provide the complexity for OBST and Knapsack problem


 OBST: O(n2)
 Knapsack: 2n

6. What are the applications of Graph colouring Problem?


 Time Tabling
 Scheduling
 Register Allocation
 Channel Assignment
 Map colouring
7. Define P class
 The class P consists of those problems that are solvable in polynomial time, i.e.
these problems can be solved in time O(nk) in worst-case, where k is
constant.These problems are called tractable

8. Define NP class
 The class NP consists of those problems that are verifiable in polynomial time.
NP is the class of decision problems for which it is easy to check the correctness
of a claimed answer, with the aid of a little extra information.
 Every problem in this class can be solved in exponential time using exhaustive
search

9. Summarize the terms i)Tractable problem ii)Intractable problem

 Tractable Problem: a problem that is solvable by a polynomial-time algorithm.


The upper bound is polynomial.
e.g
Searching an unordered list
Searching an ordered list
Multiplication of integers
 Intractable Problem: a problem that cannot be solved by a polynomial-time
algorithm. The lower bound is exponential.
e.g
Towers of Hanoi

10. Explain the term “Memoization”


 Memoization is a term describing an optimization technique where you cache
previously computed results, and return the cached result when the same
computation is needed again.

11. Give examples for NP Hard problems


 The following problems are NP-Hard
 The circuit-satisfiability problem
 Set Cover
 Vertex Cover
 Travelling Salesman Problem
12. Differentiate promising and non-Promising nodes
 A node in state-space tree is said to be promising, if it corresponds to a partially
constructed solution that may still lead to complete solution. Otherwise, that node
is non-promising

13. Differentiate M-Colourability and M-optimizable problem.


M-optimizable problem
 The M – colourability optimization problem deals with the smallest integer m for
which the graph G can be colored. The integer is known as a chromatic number
of the graph.
M-Colourability
 An undirected graph is given. There is also provided m colors. The problem is to
find if it is possible to assign nodes with m different colors, such that no two
adjacent vertices of the graph are of the same colors.

14. Write an Euclid’s algorithm for GCD of 2 numbers.

while n ≠ 0 do
r ← m mod n
m← n
n←r
return m

15. Depict the relation between P calss ,NP hard and NP complete

16. What is a state-space tree?


The tree constructed to implement backtracking with the choices for the
components is called the state-space tree. Its root represents initial state before the
search for a solution and the nodes at each level represent the choices made for the
corresponding component of a solution.

17.Define Chromatic number


The chromatic number of a graph G is the smallest number of color need to color the
verities of G, so that no 2 adjacent vertices shave the same color.
18. Compute the GCD (84,48) using Extended Euclid’s algorithm.

Das könnte Ihnen auch gefallen