SlideShare a Scribd company logo
CHINE! 6
Limitation of Algorithms
—=<3=——=G=——=c=——=c=——«:>=——=a=——=Q=—{¢}+
2.2.1. Limitations of Algorithm
There are many algorithms for solving a variety of different problems.
They are very powerful instruments, especially when they are executed by modern
computers. The power of algorithms is limited because of the following reasons:
0 There are some problems cannot be solved by any algorithm.
I There are some problems can be solved algorithmically but not in
polynomial time.
0 There are some problems can be solved in polynomial time by some
algorithms, but they are usually lower bounds on their efficiency.
Algorithms limits are identified by the following:
in Lower-Bound Arguments
in Decision Trees
t P, NP and NP—Complete Problems
2.2.2. Lower-Bound Arguments
We can look at the efficiency of an algorithm two ways. We can establish
its asymptotic efiiciency class (say, for the worst case) and see where this class
stands with respect to the hierarchy of efliciency classes.
For example, selection sort, whose efficiency is quadratic, is a reasonably
fast algorithm, whereas the algorithm for the Tower of Hanoi problem is very slow
because its efficiency is exponential.
Lower bounds means estimating the minimum amount of work needed to
solve the problem. We present several methods for establishing lower bounds and
illustrate them with specific examples.
Trivial Lower Bounds
Information-Theoretic Arguments
Adversary Arguments
Problem Reduction
er‘F’E
In analyzing the efficiency of specific algorithms in the preceding, we
should distinguish between a lower-bound class and a minimum number of times a
particular operation needs to be executed.
Trivial Lower Bounds
The simplest method of obtaining a lower-bound class is based on counting
the number of items in the problem’s input that must be processed and the number
of output items that need to be produced
Since any algorithm must at least “read” all the items it needs to process
and “write” all its outputs, such a count yields a trivial lower bound
For example, any algorithm for generating all permutations of n distinct
items must be in Q(n!) because the size of the output is n!. And this bound is tight
because good algorithms for generating permutations spend a constant time on each
of them except the initial one.
Consider the problem of evaluating a polynomial of degree n at a given
point x, given its coefficients an, an—l, . . . , a0. p(x) = anxn + an-lx‘fl + . . . + an. All
the coefficients have to be processed by any polynomial-evaluation algorithm. i.e
Q(n). This is tight lower bound.
Similarly, a trivial lower bound for computing the product of two 11 X n
matrices is Q(n2) because any such algorithm has to process 2n2 elements in the
input matrices and generate n2 elements of the product. It is still unknown,
however, whether this bound is tight.
The trivial bound for the traveling salesman problem is Q(n2), because its
input is n(n-I)/2 intercity distances and its output is a list of n + 1 cities making up
an optimal tour. But this bound is useless because there is no known algorithm with
the running time being a polynomial function.
Detemiining the lower bound lies in which part of an input must be
processed by any algorithm solving the problem. For example, searching for an
element of a given value in a sorted array does not require processing all its
elements.
Information-Theoretic Arguments
The information-theoretical approach seeks to establish a lower bound
based on the amount of information it has to produce by algorithm.
Consider an example “Game of guessing number”, the well-known game
of deducing a positive integer between 1 and 11 selected by somebody by asking
that person questions with yes/no answers. The amount of uncertainty that any
algorithm solving this problem has to resolve can be measured by log n.
The number of bits needed to specify a particular number among the 11
possibilities. Each answer to the question gives information about each bit.
Is the first bit zero? —> No—> first bit is 1
Is the second bit zero? —> Yes—> second bit is 0
Is the third bit zero? —> Yes—> third bit is 0
Is the forth bit zero? —> Yes—> forth bit is 0
The number in binary is 1000, i.e.8 in decimal value.
The above approach is called the information-theoretic argument because
of its connection to information theory. This is useful for finding information-
theoretic lower bounds for many problems involving comparisons, including
sorting and searching.
Its underlying idea can be realized the mechanism of decision trees.
Because
Adversary Arguments
Adversary Argument is a method of proving by playing a role of
adversary (opponent) in which algorithm has to work more for adjusting input
consistently.
Consider the Game of guessing number between positive integer l and n
by asking a person (Adversary) with yes/no type answers for questions. After each
question at least one-half of the numbers reduced. If an algorithm stops before the
size of the set is reduced to l, the adversary can exhibit a number.
Any algorithm needs log 11 iterations to shrink an n—element set to a one-
element set by halving and rounding up the size of the remaining set. Hence, at
least log 11 questions need to be asked by any algorithm in the worst case. This
example illustrates the adversary method for establishing lower bounds.
Consider the problem of merging two sorted lists of size n a1< a2 < . . . < an
and b1< b2 < . .< bn into a single sorted list of size 2n. For simplicity, we assume
that all the a’s and b’s are distinct, which gives the problem a unique solution.
Merging is done by repeatedly comparing the first elements in the
remaining lists and outputting the smaller among them. The number of key
comparisons (lower bound) in the worst case for this algorithm for merging is 2n —
1.
Problem Reduction
Problem reduction is a method in which a difficult unsolvable problem P is
reduced to another solvable problem B which can be solved by a known algorithm.
A similar reduction idea can be used for finding a lower bound. To show
that problem P is at least as hard as another problem Q with a known lower bound,
we need to reduce Q to P (not P to Q!). In other words, we should show that an
arbitrary instance of problem Q can be transformed to an instance of problem P, so
any algorithm solving P would solve Q as well. Then a lower bound for Q will be a
lower bound for P. Below table lists several important problems that are often used
for this purpose.
Problem Lower bound Tightness
Sorting 9(11 log 11) yes
searching in a sorted array £2 (log 11) yes
element uniqueness problem [2 (n log 11) yes
multiplication of n—digit integers 9(11) unknown
multiplication of n X n matrices 9(112) unknown
Consider the Euclidean minimum spanning tree problem as an example of
establishing a lower bound by reduction:
Given n points in the Cartesian plane, construct a tree of minimum total
length whose vertices are the given points. As a problem with a known lower
bound, we use the element uniqueness problem.
We can transform any set x1, x2, . . . , xn of 11 real numbers into a set of n
points in the Cartesian plane by simply adding 0 as the points’ y coordinate: (x1, 0),
(x2, 0), . . . , (xn, 0). Let T be a minimum spanning tree found for this set of points.
Since T must contain a shortest edge, checking whether T contains a zero length
edge will answer the question about uniqueness of the given numbers. This
reduction implies that Q (n log n) is a lower bound for the Euclidean minimum
spanning tree problem.
Note: Limitations of algorithm can be studied by obtaining lower bound
efficiency
2.2.3. Decision Trees
Important algorithms like sorting and searching are based on comparing
items of their inputs. The study of the performance of such algorithm is called a
decision tree. As an example, Below Figure presents a decision tree of an algorithm
for finding a minimum of three numbers. Each internal node of a binary decision
tree represents a key comparison indicated in the node.
Fig .' Decision tree for finding a minimum of three numbers.
Consider a binary decision tree with height h and leaves 11. and height h,
then h 2[ log n ]. A biriaiy tree of height h with the largest number of leaves on the
last level is 2“. In other words, 2“ 2 n, which puts a lower bound on the heights of
binary decision trees. Hence the worst-case number of comparisons made by any
comparison-based algorithm for the problem is called the information theoretic
lower bound.
Iabc
Yes a<__ b>%
as... 32:../' _ /. .
ebc Che /c_ba
./ “as /-"““. -- “a...
yeS.//qu H‘s—O -/b<.a ”BEE VE-qqcy veS"/b<.a ')
|C<a<b| |b<a<C| |b<C<a||C<b<a|
Fig .' Decision tree for the tree-element selection sort.
A triple above a node indicates the state of the array being sorted. Note two
redundant comparisons b < a with a single possible outcome because of the results
of some previously made comparisons.
abc
fl.
es /' “a.V .. a < b .. no
abc back
es "/fi‘x“ __/" K.Y Q 4 c .133“ no yes a < c .5 no
-<—< C _<— < C
Y93/” E/ “H ‘x no
a<./C__j: jb<cfl
Fig .' Decision treefor the tree-e-lement selection sort
The three-element insertion sort whose decision tree is given in Figure 5.3,
this number is (2 + 3 + 3 + 2 + 3 + 3)/6 = 2.66. Under the standard assumption that
all n! outcomes of sorting are equally likely, the following lower bound on the
average number of comparisons Cavg made by any comparison-based algorithm in
sorting an n—element list has been proved:
Cavg(n) 2 log2 n!.
Decision tree is a convenient model of algorithms involving comparisons in
which
0 internal nodes represent comparisons
0 leaves represent outcomes (or input cases)
Decision Trees and Sorting Algorithms
0 Any comparison-based sorting algorithm can be represented by a decision
tree (for each fixed n)
Number of leaves (outcomes) 3 n!
Height of binary tree with n! leaves >=[log2n!]
0 Minimum number of comparisons in the worst case 3 éloggnlu for any
comparison-based sorting algorithm, since the longest path represents the
worst case and its length is the height
0 [log2n!]n loggn (by Sterling approximation)
0 This lower bound is tight (mergesort or heapsort)
Decision Trees for Searching a Sorted Array
Decision trees can be used for establishing lower bounds on the number of
key comparisons in searching a sorted array of 11 keys: A[0]<A[l]< . . .<A[n - l].
The principal algorithm for this problem is binary search. The number of
comparisons made by binary search in the worst case, Cwom(n), is given by the
formula
Cwomfil) = [log2 I1] + 1: [10g2(11+1)]
A
“’"Alil'" >—
< : '.‘>
—""’Al0|_'_','_.‘..‘>— am 59'?—
‘E = '3‘ ‘1'. = :3
|<A[U|| l AID] | lwotannl |LA|1LA12|1| lam l ./"A[3
DWELNB]: lAisI | banal
Fig: Ternary decision tree for binary search in a four-element array.
./""_"‘.
ffll/
< >
/"‘ ' W /"' ' ' ' ‘X
.i‘_”‘3l./' xii?!
< 2: ‘C b
<AIOI W0]. AM] (Ah 1. A[Z]! /-:q[3-]--,_
x..- ___/
< >
{A[Zl. A[3]l > AB]
Fig: Binary decision tree for binary search in a four-element array.
As comparison of the decision trees in the above illustrates, the biriaiy
decision tree is simply the temaiy decision tree with all the middle subtrees
eliminated. Applying inequality to such biriaiy decision trees immediately yields
Cum/n) 2 [10g2(11+1)]
2.2.4. P - Class
The class P consist of those problems that are solvable in polynomial time
that is in time 0 (nk) for some constant’ k’ where n is input size.
0 The worst-case time complexity is limited by the polynomial function of its
input size.
0 The class of problems where the solution can discovered “quickly”
In time polynomial in the size of the input
Example
Sorting 9T(n) = O(n2), T(n) = O(n log n)
Searching 9T(n) = O(n), T(n) = lO(log n)
Matrix multiplication 9T(n) = O(n3), T(n) = O(n2'83)
0 P Problems are the set of all decision issues that can be solved by
algorithms with polynomial time requirements.
0 More specifically, they are problems that can be solved in time O(nk) for
some constant k, where n is the size of the input to the problem.
0 The key is that n is the size of input.
Intractable and tractable
0 An issue is said to be intractable if it is not possible to be solved by a
polynomial-time algorithm.
0 Conversely, the problem is said to be tractable if a polynomial algorithm
can solve it.
2.2.5. NP-class
The class NP consist of those problems that are verifiable in polynomial
time that is given a certificate of a solution use could verify that the certificate is
correct in time polynomial in the size of the input to the problem.
0 Nondetemiinistic Polynomial time
0 The class of problems where the solution can verified “quickly”
0 In time polynomial in the size of the input
Example
TSP,
integer knapsack problem,
graph coloring,
Hamilton Circuit,
partition problem,
‘/ integer linear programming
In discussing the theory of NP, we only limit the decision problem.
Decision issue is a problem whose solution is only ”yes” or ”no” answer.
xxxxx
Example:
Given an integer x. Determine whether the element x is in the table?
Given an integer x. Determine whether x is prime number?
School
Movies
Planter's Farm
3+ b+c+d+e : minimum weight TSOP = minimum weight
3+ D+c+d+e -= I TSDP = total weight<x
Traveling Salesman Optimization Problem (T SOP) is a matter of determining a
tour with a minimum total of minimum weights.
(*TSP is commonly known).
Traveling Salesman Decision Problem (T SDP) is a matter of determining whether
there is a tour with the total weight of the sides not exceeding the value x.
Example: if the problem Traveling Salesman Optimization Problem (TSOP)
minimum tour is 20,
Then the answer to the problem of Traveling Salesman Decision Problem (TSDP) is
”yes” ifx >= 20, and ”no” ifx <20.
2.2.6. NP complete problems
NP hard problem
0 Class of decision problems which are at least as hard as the hardest
problems in NP.
0 Problems that are NP-hard do not have to be elements of NP', indeed, they
may not even be decidable.
Is P = NP?
Any problem in P is also in NP:
P E NP
The big (and open question) is whether NP E P or P = NP
i.e., if it is always easy to check a solution, should it also be easy to find a solution?
Most computer scientists believe that this is false but we do not have a proof ...
NP-Completeness (informally)
NP-complete problems are defined as the hardest problems in NP
Most practical problems turn out to be either P or NP-complete.
Study NP-complete problems
Reductions
Reduction is a way of saying that one problem is “easier” than another.
We say that problem A is easier than problem B, (i.e., we write “A 5 B”)
if we can solve A using the algorithm that solves B.
Idea: transform the inputs of A to inputs of B
yes yes
(I
f '3 Problem B < no
no —
Problem A
Polynomial Reductions
0 Given two problems A, B, we say that A is polynomially reducible to B (A
S p B) if:
0 There exists a function f that converts the input of A to inputs of B in
polynomial time
0 A(i) = YES <<>> B(f(i)) = YES
NP-Completeness (formally)
A problem B is NP-complete if:
(1)B ENP
(2)A SprorallA E NP
0 If B satisfies only property (2) we say that B is NP-hard
0 No polynomial time algorithm has been discovered for an NP-Complete
problem
0 No one has ever proven that no polynomial time algorithm can exist for any
NP-Complete problem
f B Problem B
Problem A
yes
yes —
< no
no —>
IfA£pBandB €P,thenAEP
ifA£pBandA8 P,thenB 6 P
Proving Polynomial Time
0L f B Polynomial time
algorithm to decide B
{—i
no
Polynomial time algorithm to decide A
1. Use a polynomial time reduction algorithm to transform A into B
2. Run a known polynomial time algorithm for B
3. Use the answer for B as the answer for A

More Related Content

What's hot

Algorithm Using Divide And Conquer
Algorithm Using Divide And ConquerAlgorithm Using Divide And Conquer
Algorithm Using Divide And Conquer
UrviBhalani2
 
finding Min and max element from given array using divide & conquer
finding Min and max element from given array using  divide & conquer finding Min and max element from given array using  divide & conquer
finding Min and max element from given array using divide & conquer
Swati Kulkarni Jaipurkar
 
Sensitivity analysis linear programming copy
Sensitivity analysis linear programming   copySensitivity analysis linear programming   copy
Sensitivity analysis linear programming copy
Kiran Jadhav
 
08 decrease and conquer spring 15
08 decrease and conquer spring 1508 decrease and conquer spring 15
08 decrease and conquer spring 15
Hira Gul
 
Algorithm in computer science
Algorithm in computer scienceAlgorithm in computer science
Algorithm in computer science
Riazul Islam
 
Divide and Conquer Case Study
Divide and Conquer Case StudyDivide and Conquer Case Study
Divide and Conquer Case Study
KushagraChadha1
 
Linear Regression
Linear RegressionLinear Regression
Linear Regression
VARUN KUMAR
 
Unit 2
Unit 2Unit 2
Unit 2
guna287176
 
Undecidable Problems - COPING WITH THE LIMITATIONS OF ALGORITHM POWER
Undecidable Problems - COPING WITH THE LIMITATIONS OF ALGORITHM POWERUndecidable Problems - COPING WITH THE LIMITATIONS OF ALGORITHM POWER
Undecidable Problems - COPING WITH THE LIMITATIONS OF ALGORITHM POWER
muthukrishnavinayaga
 
The Complexity Of Primality Testing
The Complexity Of Primality TestingThe Complexity Of Primality Testing
The Complexity Of Primality Testing
Mohammad Elsheikh
 
Algorithm Design and Complexity - Course 5
Algorithm Design and Complexity - Course 5Algorithm Design and Complexity - Course 5
Algorithm Design and Complexity - Course 5Traian Rebedea
 
Data Structures- Hashing
Data Structures- Hashing Data Structures- Hashing
Data Structures- Hashing
hemalatha athinarayanan
 
Optimization problems
Optimization problemsOptimization problems
Optimization problems
Ruchika Sinha
 
On the lambert w function
On the lambert w functionOn the lambert w function
On the lambert w function
TrungKienVu3
 
INDICES & LOGARITHMS
INDICES & LOGARITHMSINDICES & LOGARITHMS
INDICES & LOGARITHMS
Puna Ripiye
 

What's hot (20)

Algorithm Using Divide And Conquer
Algorithm Using Divide And ConquerAlgorithm Using Divide And Conquer
Algorithm Using Divide And Conquer
 
algorithm Unit 2
algorithm Unit 2 algorithm Unit 2
algorithm Unit 2
 
algorithm Unit 4
algorithm Unit 4 algorithm Unit 4
algorithm Unit 4
 
finding Min and max element from given array using divide & conquer
finding Min and max element from given array using  divide & conquer finding Min and max element from given array using  divide & conquer
finding Min and max element from given array using divide & conquer
 
Sensitivity analysis linear programming copy
Sensitivity analysis linear programming   copySensitivity analysis linear programming   copy
Sensitivity analysis linear programming copy
 
algorithm unit 1
algorithm unit 1algorithm unit 1
algorithm unit 1
 
08 decrease and conquer spring 15
08 decrease and conquer spring 1508 decrease and conquer spring 15
08 decrease and conquer spring 15
 
algorithm Unit 5
algorithm Unit 5 algorithm Unit 5
algorithm Unit 5
 
Algorithm in computer science
Algorithm in computer scienceAlgorithm in computer science
Algorithm in computer science
 
Divide and Conquer Case Study
Divide and Conquer Case StudyDivide and Conquer Case Study
Divide and Conquer Case Study
 
Linear Regression
Linear RegressionLinear Regression
Linear Regression
 
L16
L16L16
L16
 
Unit 2
Unit 2Unit 2
Unit 2
 
Undecidable Problems - COPING WITH THE LIMITATIONS OF ALGORITHM POWER
Undecidable Problems - COPING WITH THE LIMITATIONS OF ALGORITHM POWERUndecidable Problems - COPING WITH THE LIMITATIONS OF ALGORITHM POWER
Undecidable Problems - COPING WITH THE LIMITATIONS OF ALGORITHM POWER
 
The Complexity Of Primality Testing
The Complexity Of Primality TestingThe Complexity Of Primality Testing
The Complexity Of Primality Testing
 
Algorithm Design and Complexity - Course 5
Algorithm Design and Complexity - Course 5Algorithm Design and Complexity - Course 5
Algorithm Design and Complexity - Course 5
 
Data Structures- Hashing
Data Structures- Hashing Data Structures- Hashing
Data Structures- Hashing
 
Optimization problems
Optimization problemsOptimization problems
Optimization problems
 
On the lambert w function
On the lambert w functionOn the lambert w function
On the lambert w function
 
INDICES & LOGARITHMS
INDICES & LOGARITHMSINDICES & LOGARITHMS
INDICES & LOGARITHMS
 

Similar to Daa chapter6

Confidence interval two tail tests-lower bounds upperbounds
Confidence interval two tail tests-lower bounds upperboundsConfidence interval two tail tests-lower bounds upperbounds
Confidence interval two tail tests-lower bounds upperbounds
ssuser3c3f88
 
Cs6402 design and analysis of algorithms may june 2016 answer key
Cs6402 design and analysis of algorithms may june 2016 answer keyCs6402 design and analysis of algorithms may june 2016 answer key
Cs6402 design and analysis of algorithms may june 2016 answer key
appasami
 
Computer Science Exam Help
Computer Science Exam Help Computer Science Exam Help
Computer Science Exam Help
Programming Exam Help
 
Unit-3 greedy method, Prim's algorithm, Kruskal's algorithm.pdf
Unit-3 greedy method, Prim's algorithm, Kruskal's algorithm.pdfUnit-3 greedy method, Prim's algorithm, Kruskal's algorithm.pdf
Unit-3 greedy method, Prim's algorithm, Kruskal's algorithm.pdf
yashodamb
 
Unit 5
Unit 5Unit 5
Unit 5
guna287176
 
Undecidable Problems and Approximation Algorithms
Undecidable Problems and Approximation AlgorithmsUndecidable Problems and Approximation Algorithms
Undecidable Problems and Approximation Algorithms
Muthu Vinayagam
 
Perform brute force
Perform brute forcePerform brute force
Perform brute force
SHC
 
Solution 3.
Solution 3.Solution 3.
Solution 3.
sansaristic
 
Unit 2 in daa
Unit 2 in daaUnit 2 in daa
Unit 2 in daa
Nv Thejaswini
 
Analysis and Design of Algorithms notes
Analysis and Design of Algorithms  notesAnalysis and Design of Algorithms  notes
Analysis and Design of Algorithms notes
Prof. Dr. K. Adisesha
 
Dynamic programming1
Dynamic programming1Dynamic programming1
Dynamic programming1
debolina13
 
lecture 1
lecture 1lecture 1
lecture 1sajinsc
 
ch11-04-27-15.ppt
ch11-04-27-15.pptch11-04-27-15.ppt
ch11-04-27-15.ppt
ssuser15a62a
 
Unit 3
Unit 3Unit 3
Unit 3
guna287176
 
Algorithm chapter 1
Algorithm chapter 1Algorithm chapter 1
Algorithm chapter 1chidabdu
 

Similar to Daa chapter6 (20)

Confidence interval two tail tests-lower bounds upperbounds
Confidence interval two tail tests-lower bounds upperboundsConfidence interval two tail tests-lower bounds upperbounds
Confidence interval two tail tests-lower bounds upperbounds
 
Cs6402 design and analysis of algorithms may june 2016 answer key
Cs6402 design and analysis of algorithms may june 2016 answer keyCs6402 design and analysis of algorithms may june 2016 answer key
Cs6402 design and analysis of algorithms may june 2016 answer key
 
Computer Science Exam Help
Computer Science Exam Help Computer Science Exam Help
Computer Science Exam Help
 
Unit-3 greedy method, Prim's algorithm, Kruskal's algorithm.pdf
Unit-3 greedy method, Prim's algorithm, Kruskal's algorithm.pdfUnit-3 greedy method, Prim's algorithm, Kruskal's algorithm.pdf
Unit-3 greedy method, Prim's algorithm, Kruskal's algorithm.pdf
 
Unit 5
Unit 5Unit 5
Unit 5
 
Unit 5
Unit 5Unit 5
Unit 5
 
Ada notes
Ada notesAda notes
Ada notes
 
Unit7
Unit7Unit7
Unit7
 
Undecidable Problems and Approximation Algorithms
Undecidable Problems and Approximation AlgorithmsUndecidable Problems and Approximation Algorithms
Undecidable Problems and Approximation Algorithms
 
Perform brute force
Perform brute forcePerform brute force
Perform brute force
 
Solution 3.
Solution 3.Solution 3.
Solution 3.
 
Unit 2 in daa
Unit 2 in daaUnit 2 in daa
Unit 2 in daa
 
Analysis and Design of Algorithms notes
Analysis and Design of Algorithms  notesAnalysis and Design of Algorithms  notes
Analysis and Design of Algorithms notes
 
Dynamic programming1
Dynamic programming1Dynamic programming1
Dynamic programming1
 
lecture 1
lecture 1lecture 1
lecture 1
 
ch11-04-27-15.ppt
ch11-04-27-15.pptch11-04-27-15.ppt
ch11-04-27-15.ppt
 
Mit6 006 f11_quiz1
Mit6 006 f11_quiz1Mit6 006 f11_quiz1
Mit6 006 f11_quiz1
 
Unit 3
Unit 3Unit 3
Unit 3
 
Unit 3
Unit 3Unit 3
Unit 3
 
Algorithm chapter 1
Algorithm chapter 1Algorithm chapter 1
Algorithm chapter 1
 

More from B.Kirron Reddi

What after graduation_-_mba
What after graduation_-_mbaWhat after graduation_-_mba
What after graduation_-_mba
B.Kirron Reddi
 
What after graduation_-_banks
What after graduation_-_banksWhat after graduation_-_banks
What after graduation_-_banks
B.Kirron Reddi
 
What after graduation_-_mca
What after graduation_-_mcaWhat after graduation_-_mca
What after graduation_-_mca
B.Kirron Reddi
 
Daa chpater14
Daa chpater14Daa chpater14
Daa chpater14
B.Kirron Reddi
 
Daa chpater 12
Daa chpater 12Daa chpater 12
Daa chpater 12
B.Kirron Reddi
 
Daa chapter13
Daa chapter13Daa chapter13
Daa chapter13
B.Kirron Reddi
 
Daa chapter11
Daa chapter11Daa chapter11
Daa chapter11
B.Kirron Reddi
 
Daa chapter10
Daa chapter10Daa chapter10
Daa chapter10
B.Kirron Reddi
 
Daa chapter9
Daa chapter9Daa chapter9
Daa chapter9
B.Kirron Reddi
 
Daa chapter8
Daa chapter8Daa chapter8
Daa chapter8
B.Kirron Reddi
 
Daa chapter7
Daa chapter7Daa chapter7
Daa chapter7
B.Kirron Reddi
 
Daa chapter5
Daa chapter5Daa chapter5
Daa chapter5
B.Kirron Reddi
 
Daa chapter4
Daa chapter4Daa chapter4
Daa chapter4
B.Kirron Reddi
 
Daa chapter 3
Daa chapter 3Daa chapter 3
Daa chapter 3
B.Kirron Reddi
 
Daa chapter 2
Daa chapter 2Daa chapter 2
Daa chapter 2
B.Kirron Reddi
 
Daa chapter 1
Daa chapter 1Daa chapter 1
Daa chapter 1
B.Kirron Reddi
 
Daa contents by B.Kirron Reddi
Daa contents by B.Kirron ReddiDaa contents by B.Kirron Reddi
Daa contents by B.Kirron Reddi
B.Kirron Reddi
 
Searching and sorting by B kirron Reddi
Searching and sorting by B kirron ReddiSearching and sorting by B kirron Reddi
Searching and sorting by B kirron Reddi
B.Kirron Reddi
 

More from B.Kirron Reddi (18)

What after graduation_-_mba
What after graduation_-_mbaWhat after graduation_-_mba
What after graduation_-_mba
 
What after graduation_-_banks
What after graduation_-_banksWhat after graduation_-_banks
What after graduation_-_banks
 
What after graduation_-_mca
What after graduation_-_mcaWhat after graduation_-_mca
What after graduation_-_mca
 
Daa chpater14
Daa chpater14Daa chpater14
Daa chpater14
 
Daa chpater 12
Daa chpater 12Daa chpater 12
Daa chpater 12
 
Daa chapter13
Daa chapter13Daa chapter13
Daa chapter13
 
Daa chapter11
Daa chapter11Daa chapter11
Daa chapter11
 
Daa chapter10
Daa chapter10Daa chapter10
Daa chapter10
 
Daa chapter9
Daa chapter9Daa chapter9
Daa chapter9
 
Daa chapter8
Daa chapter8Daa chapter8
Daa chapter8
 
Daa chapter7
Daa chapter7Daa chapter7
Daa chapter7
 
Daa chapter5
Daa chapter5Daa chapter5
Daa chapter5
 
Daa chapter4
Daa chapter4Daa chapter4
Daa chapter4
 
Daa chapter 3
Daa chapter 3Daa chapter 3
Daa chapter 3
 
Daa chapter 2
Daa chapter 2Daa chapter 2
Daa chapter 2
 
Daa chapter 1
Daa chapter 1Daa chapter 1
Daa chapter 1
 
Daa contents by B.Kirron Reddi
Daa contents by B.Kirron ReddiDaa contents by B.Kirron Reddi
Daa contents by B.Kirron Reddi
 
Searching and sorting by B kirron Reddi
Searching and sorting by B kirron ReddiSearching and sorting by B kirron Reddi
Searching and sorting by B kirron Reddi
 

Recently uploaded

special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
chanes7
 
Group Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana BuscigliopptxGroup Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana Buscigliopptx
ArianaBusciglio
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 

Recently uploaded (20)

special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
 
Group Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana BuscigliopptxGroup Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana Buscigliopptx
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 

Daa chapter6

  • 1. CHINE! 6 Limitation of Algorithms —=<3=——=G=——=c=——=c=——«:>=——=a=——=Q=—{¢}+ 2.2.1. Limitations of Algorithm There are many algorithms for solving a variety of different problems. They are very powerful instruments, especially when they are executed by modern computers. The power of algorithms is limited because of the following reasons: 0 There are some problems cannot be solved by any algorithm. I There are some problems can be solved algorithmically but not in polynomial time. 0 There are some problems can be solved in polynomial time by some algorithms, but they are usually lower bounds on their efficiency. Algorithms limits are identified by the following: in Lower-Bound Arguments in Decision Trees t P, NP and NP—Complete Problems 2.2.2. Lower-Bound Arguments We can look at the efficiency of an algorithm two ways. We can establish its asymptotic efiiciency class (say, for the worst case) and see where this class stands with respect to the hierarchy of efliciency classes. For example, selection sort, whose efficiency is quadratic, is a reasonably fast algorithm, whereas the algorithm for the Tower of Hanoi problem is very slow because its efficiency is exponential. Lower bounds means estimating the minimum amount of work needed to solve the problem. We present several methods for establishing lower bounds and illustrate them with specific examples. Trivial Lower Bounds Information-Theoretic Arguments Adversary Arguments Problem Reduction er‘F’E In analyzing the efficiency of specific algorithms in the preceding, we should distinguish between a lower-bound class and a minimum number of times a particular operation needs to be executed.
  • 2. Trivial Lower Bounds The simplest method of obtaining a lower-bound class is based on counting the number of items in the problem’s input that must be processed and the number of output items that need to be produced Since any algorithm must at least “read” all the items it needs to process and “write” all its outputs, such a count yields a trivial lower bound For example, any algorithm for generating all permutations of n distinct items must be in Q(n!) because the size of the output is n!. And this bound is tight because good algorithms for generating permutations spend a constant time on each of them except the initial one. Consider the problem of evaluating a polynomial of degree n at a given point x, given its coefficients an, an—l, . . . , a0. p(x) = anxn + an-lx‘fl + . . . + an. All the coefficients have to be processed by any polynomial-evaluation algorithm. i.e Q(n). This is tight lower bound. Similarly, a trivial lower bound for computing the product of two 11 X n matrices is Q(n2) because any such algorithm has to process 2n2 elements in the input matrices and generate n2 elements of the product. It is still unknown, however, whether this bound is tight. The trivial bound for the traveling salesman problem is Q(n2), because its input is n(n-I)/2 intercity distances and its output is a list of n + 1 cities making up an optimal tour. But this bound is useless because there is no known algorithm with the running time being a polynomial function. Detemiining the lower bound lies in which part of an input must be processed by any algorithm solving the problem. For example, searching for an element of a given value in a sorted array does not require processing all its elements. Information-Theoretic Arguments The information-theoretical approach seeks to establish a lower bound based on the amount of information it has to produce by algorithm. Consider an example “Game of guessing number”, the well-known game of deducing a positive integer between 1 and 11 selected by somebody by asking that person questions with yes/no answers. The amount of uncertainty that any algorithm solving this problem has to resolve can be measured by log n. The number of bits needed to specify a particular number among the 11 possibilities. Each answer to the question gives information about each bit. Is the first bit zero? —> No—> first bit is 1 Is the second bit zero? —> Yes—> second bit is 0
  • 3. Is the third bit zero? —> Yes—> third bit is 0 Is the forth bit zero? —> Yes—> forth bit is 0 The number in binary is 1000, i.e.8 in decimal value. The above approach is called the information-theoretic argument because of its connection to information theory. This is useful for finding information- theoretic lower bounds for many problems involving comparisons, including sorting and searching. Its underlying idea can be realized the mechanism of decision trees. Because Adversary Arguments Adversary Argument is a method of proving by playing a role of adversary (opponent) in which algorithm has to work more for adjusting input consistently. Consider the Game of guessing number between positive integer l and n by asking a person (Adversary) with yes/no type answers for questions. After each question at least one-half of the numbers reduced. If an algorithm stops before the size of the set is reduced to l, the adversary can exhibit a number. Any algorithm needs log 11 iterations to shrink an n—element set to a one- element set by halving and rounding up the size of the remaining set. Hence, at least log 11 questions need to be asked by any algorithm in the worst case. This example illustrates the adversary method for establishing lower bounds. Consider the problem of merging two sorted lists of size n a1< a2 < . . . < an and b1< b2 < . .< bn into a single sorted list of size 2n. For simplicity, we assume that all the a’s and b’s are distinct, which gives the problem a unique solution. Merging is done by repeatedly comparing the first elements in the remaining lists and outputting the smaller among them. The number of key comparisons (lower bound) in the worst case for this algorithm for merging is 2n — 1. Problem Reduction Problem reduction is a method in which a difficult unsolvable problem P is reduced to another solvable problem B which can be solved by a known algorithm. A similar reduction idea can be used for finding a lower bound. To show that problem P is at least as hard as another problem Q with a known lower bound, we need to reduce Q to P (not P to Q!). In other words, we should show that an arbitrary instance of problem Q can be transformed to an instance of problem P, so any algorithm solving P would solve Q as well. Then a lower bound for Q will be a
  • 4. lower bound for P. Below table lists several important problems that are often used for this purpose. Problem Lower bound Tightness Sorting 9(11 log 11) yes searching in a sorted array £2 (log 11) yes element uniqueness problem [2 (n log 11) yes multiplication of n—digit integers 9(11) unknown multiplication of n X n matrices 9(112) unknown Consider the Euclidean minimum spanning tree problem as an example of establishing a lower bound by reduction: Given n points in the Cartesian plane, construct a tree of minimum total length whose vertices are the given points. As a problem with a known lower bound, we use the element uniqueness problem. We can transform any set x1, x2, . . . , xn of 11 real numbers into a set of n points in the Cartesian plane by simply adding 0 as the points’ y coordinate: (x1, 0), (x2, 0), . . . , (xn, 0). Let T be a minimum spanning tree found for this set of points. Since T must contain a shortest edge, checking whether T contains a zero length edge will answer the question about uniqueness of the given numbers. This reduction implies that Q (n log n) is a lower bound for the Euclidean minimum spanning tree problem. Note: Limitations of algorithm can be studied by obtaining lower bound efficiency 2.2.3. Decision Trees Important algorithms like sorting and searching are based on comparing items of their inputs. The study of the performance of such algorithm is called a decision tree. As an example, Below Figure presents a decision tree of an algorithm for finding a minimum of three numbers. Each internal node of a binary decision tree represents a key comparison indicated in the node.
  • 5. Fig .' Decision tree for finding a minimum of three numbers. Consider a binary decision tree with height h and leaves 11. and height h, then h 2[ log n ]. A biriaiy tree of height h with the largest number of leaves on the last level is 2“. In other words, 2“ 2 n, which puts a lower bound on the heights of binary decision trees. Hence the worst-case number of comparisons made by any comparison-based algorithm for the problem is called the information theoretic lower bound. Iabc Yes a<__ b>% as... 32:../' _ /. . ebc Che /c_ba ./ “as /-"““. -- “a... yeS.//qu H‘s—O -/b<.a ”BEE VE-qqcy veS"/b<.a ') |C<a<b| |b<a<C| |b<C<a||C<b<a| Fig .' Decision tree for the tree-element selection sort. A triple above a node indicates the state of the array being sorted. Note two redundant comparisons b < a with a single possible outcome because of the results of some previously made comparisons. abc fl. es /' “a.V .. a < b .. no abc back es "/fi‘x“ __/" K.Y Q 4 c .133“ no yes a < c .5 no -<—< C _<— < C Y93/” E/ “H ‘x no a<./C__j: jb<cfl Fig .' Decision treefor the tree-e-lement selection sort The three-element insertion sort whose decision tree is given in Figure 5.3, this number is (2 + 3 + 3 + 2 + 3 + 3)/6 = 2.66. Under the standard assumption that all n! outcomes of sorting are equally likely, the following lower bound on the
  • 6. average number of comparisons Cavg made by any comparison-based algorithm in sorting an n—element list has been proved: Cavg(n) 2 log2 n!. Decision tree is a convenient model of algorithms involving comparisons in which 0 internal nodes represent comparisons 0 leaves represent outcomes (or input cases) Decision Trees and Sorting Algorithms 0 Any comparison-based sorting algorithm can be represented by a decision tree (for each fixed n) Number of leaves (outcomes) 3 n! Height of binary tree with n! leaves >=[log2n!] 0 Minimum number of comparisons in the worst case 3 éloggnlu for any comparison-based sorting algorithm, since the longest path represents the worst case and its length is the height 0 [log2n!]n loggn (by Sterling approximation) 0 This lower bound is tight (mergesort or heapsort) Decision Trees for Searching a Sorted Array Decision trees can be used for establishing lower bounds on the number of key comparisons in searching a sorted array of 11 keys: A[0]<A[l]< . . .<A[n - l]. The principal algorithm for this problem is binary search. The number of comparisons made by binary search in the worst case, Cwom(n), is given by the formula Cwomfil) = [log2 I1] + 1: [10g2(11+1)] A “’"Alil'" >— < : '.‘> —""’Al0|_'_','_.‘..‘>— am 59'?— ‘E = '3‘ ‘1'. = :3 |<A[U|| l AID] | lwotannl |LA|1LA12|1| lam l ./"A[3 DWELNB]: lAisI | banal Fig: Ternary decision tree for binary search in a four-element array.
  • 7. ./""_"‘. ffll/ < > /"‘ ' W /"' ' ' ' ‘X .i‘_”‘3l./' xii?! < 2: ‘C b <AIOI W0]. AM] (Ah 1. A[Z]! /-:q[3-]--,_ x..- ___/ < > {A[Zl. A[3]l > AB] Fig: Binary decision tree for binary search in a four-element array. As comparison of the decision trees in the above illustrates, the biriaiy decision tree is simply the temaiy decision tree with all the middle subtrees eliminated. Applying inequality to such biriaiy decision trees immediately yields Cum/n) 2 [10g2(11+1)] 2.2.4. P - Class The class P consist of those problems that are solvable in polynomial time that is in time 0 (nk) for some constant’ k’ where n is input size. 0 The worst-case time complexity is limited by the polynomial function of its input size. 0 The class of problems where the solution can discovered “quickly” In time polynomial in the size of the input Example Sorting 9T(n) = O(n2), T(n) = O(n log n) Searching 9T(n) = O(n), T(n) = lO(log n) Matrix multiplication 9T(n) = O(n3), T(n) = O(n2'83) 0 P Problems are the set of all decision issues that can be solved by algorithms with polynomial time requirements. 0 More specifically, they are problems that can be solved in time O(nk) for some constant k, where n is the size of the input to the problem. 0 The key is that n is the size of input. Intractable and tractable
  • 8. 0 An issue is said to be intractable if it is not possible to be solved by a polynomial-time algorithm. 0 Conversely, the problem is said to be tractable if a polynomial algorithm can solve it. 2.2.5. NP-class The class NP consist of those problems that are verifiable in polynomial time that is given a certificate of a solution use could verify that the certificate is correct in time polynomial in the size of the input to the problem. 0 Nondetemiinistic Polynomial time 0 The class of problems where the solution can verified “quickly” 0 In time polynomial in the size of the input Example TSP, integer knapsack problem, graph coloring, Hamilton Circuit, partition problem, ‘/ integer linear programming In discussing the theory of NP, we only limit the decision problem. Decision issue is a problem whose solution is only ”yes” or ”no” answer. xxxxx Example: Given an integer x. Determine whether the element x is in the table? Given an integer x. Determine whether x is prime number? School Movies Planter's Farm 3+ b+c+d+e : minimum weight TSOP = minimum weight 3+ D+c+d+e -= I TSDP = total weight<x
  • 9. Traveling Salesman Optimization Problem (T SOP) is a matter of determining a tour with a minimum total of minimum weights. (*TSP is commonly known). Traveling Salesman Decision Problem (T SDP) is a matter of determining whether there is a tour with the total weight of the sides not exceeding the value x. Example: if the problem Traveling Salesman Optimization Problem (TSOP) minimum tour is 20, Then the answer to the problem of Traveling Salesman Decision Problem (TSDP) is ”yes” ifx >= 20, and ”no” ifx <20. 2.2.6. NP complete problems NP hard problem 0 Class of decision problems which are at least as hard as the hardest problems in NP. 0 Problems that are NP-hard do not have to be elements of NP', indeed, they may not even be decidable. Is P = NP? Any problem in P is also in NP: P E NP The big (and open question) is whether NP E P or P = NP i.e., if it is always easy to check a solution, should it also be easy to find a solution? Most computer scientists believe that this is false but we do not have a proof ... NP-Completeness (informally) NP-complete problems are defined as the hardest problems in NP
  • 10. Most practical problems turn out to be either P or NP-complete. Study NP-complete problems Reductions Reduction is a way of saying that one problem is “easier” than another. We say that problem A is easier than problem B, (i.e., we write “A 5 B”) if we can solve A using the algorithm that solves B. Idea: transform the inputs of A to inputs of B yes yes (I f '3 Problem B < no no — Problem A Polynomial Reductions 0 Given two problems A, B, we say that A is polynomially reducible to B (A S p B) if: 0 There exists a function f that converts the input of A to inputs of B in polynomial time 0 A(i) = YES <<>> B(f(i)) = YES NP-Completeness (formally) A problem B is NP-complete if:
  • 11. (1)B ENP (2)A SprorallA E NP 0 If B satisfies only property (2) we say that B is NP-hard 0 No polynomial time algorithm has been discovered for an NP-Complete problem 0 No one has ever proven that no polynomial time algorithm can exist for any NP-Complete problem f B Problem B Problem A yes yes — < no no —> IfA£pBandB €P,thenAEP ifA£pBandA8 P,thenB 6 P Proving Polynomial Time 0L f B Polynomial time algorithm to decide B {—i no Polynomial time algorithm to decide A 1. Use a polynomial time reduction algorithm to transform A into B 2. Run a known polynomial time algorithm for B 3. Use the answer for B as the answer for A