Lesson 8 Complexity Theory and DP
Lesson 8 Complexity Theory and DP
Definition of NP class Problem: - The set of all decision-based problems came into the
division of NP Problems who can't be solved or produced an output within polynomial time
but verified in the polynomial time. NP class contains P class as a subset. NP problems
being hard to solve.
Definition of P class Problem: - The set of decision-based problems come into the
division of P Problems who can be solved or produced an output within polynomial time. P
problems being easy to solve
Definition of Polynomial time: - If we produce an output according to the given input
within a specific amount of time such as within a minute, hours. This is known as
Polynomial time.
Definition of Non-Polynomial time: - If we produce an output according to the given
input but there are no time constraints is known as Non-Polynomial time. But yes output
will produce but time is not fixed yet.
Definition of Decision Based Problem: - A problem is called a decision problem if its
output is a simple "yes" or "no" (or you may need this of this as true/false, 0/1,
accept/reject.) We will phrase many optimization problems as decision problems. For
example, Greedy method, D.P., given a graph G= (V, E) if there exists any Hamiltonian
cycle.
Definition of NP-hard class: - Here you to satisfy the following points to come into the
division of NP-hard
If we can solve this problem in polynomial time, then we can solve all NP problems in
polynomial time
If you convert the issue into one form to another form within the polynomial time
Definition of NP-complete class: - A problem is in NP-complete, if
• It is in NP
• It is NP-hard
Dynamic programming
Dynamic Programming is the most powerful design technique for solving optimization
problems.
Divide & Conquer algorithm partition the problem into disjoint subproblems solve the
subproblems recursively and then combine their solution to solve the original problems.
Dynamic Programming is used when the subproblems are not independent, e.g. when
they share the same subproblems. In this case, divide and conquer may do more work
than necessary, because it solves the same sub problem multiple times.
Dynamic Programming solves each subproblems just once and stores the result in a table
so that it can be repeatedly retrieved if needed again.
Dynamic Programming is a Bottom-up approach- we solve all possible small problems
and then combine to obtain solutions for bigger problems.
Dynamic Programming is a paradigm of algorithm design in which an optimization
problem is solved by a combination of achieving sub-problem solutions and appearing to
the "principle of optimality".
Stages: The problem can be divided into several subproblems, which are called
stages. A stage is a small portion of a given problem. For example, in the shortest
path problem, they were defined by the structure of the graph.
States: Each stage has several states associated with it.
Decision: At each stage, there can be multiple choices out of which one of the best
decisions should be taken.
Optimal policy: It is a rule which determines the decision at each stage; a policy is
called an optimal policy if it is globally optimal. This is known as Bellman principle of
optimality.
Given the current state, the optimal choices for each of the remaining states does
not depend on the previous states or decisions.
There exist a recursive relationship that identify the optimal decisions for stage j,
given that stage j+1, has already been solved.
The final stage must be solved by itself.
Development of Dynamic Programming Algorithm