SlideShare una empresa de Scribd logo
1 de 10
Descargar para leer sin conexión
Computer Science 385
                                   Analysis of Algorithms
                                   Siena College
                                   Spring 2011

               Topic Notes: Limitations of Algorithms
We conclude with a discussion of the limitations of the power of algorithms. That is, what kinds
of problems cannot be solved by any algorithm, or which will require a minimum cost, and what
is that minimum cost?


Lower Bounds
We will first look at lower bounds, which estimate the minimum amount of work needed to solve
a given problem.
Once we have established a lower bound, we know that no algorithm can exist without performing
work equivalent to at least that of the upper bound.
Some examples:

   • the number of comparisons needed to find the largest element in a set of n numbers

   • number of comparisons needed to sort an array of size n

   • number of comparisons necessary for searching in a sorted array of n numbers

   • the number of comparisons needed to determine if all elements of an array of n elements are
     unique

   • number of multiplications needed to multiply two n × n matrices

Lower bounds may be exact counts or efficiency classes (big Ω). A lower bound is tight if there
exists an algorithm with the same efficiency as the lower bound.
Some lower bound examples:

   • sorting: lower bound Ω(n log n), tight

   • searching in a sorted array: lower bound Ω(log n), tight

   • determine element uniqueness: lower bound Ω(n log n), tight

   • n-digit integer multiplication: lower bound Ω(n), tightness unknown

   • multiplication of n × n matrices: lower bound Ω(n2 ), tightness unknown

There are a number of methods that can be used to establish lower bounds:
CS 385                              Analysis of Algorithms                            Spring 2011



   • trivial lower bounds

   • information-theoretic arguments (decision trees)

   • adversary arguments

   • problem reduction


Trivial Lower Bounds
Trivial lower bounds are based on counting the number of items that must be processed in input
and generated as output to solve a problem.
Some examples:

   • Generating all permutations of a set of n elements has a trivial lower bound of Ω(n!) since
     all n! permutations must be generated. This lower bound is tight since we have algorithms
     to do this that operate in Θ(n!).

   • Evaluating a polynomial

                                 p(x) = an xn + an−1 xn−1 + · · · + a0

      requires that each of the n ai ’s need to be processed, leading to a lower bound of Ω(n).
      Again, we have linear algorithms for this, so the bound is tight.

   • Computing the product of two n × n matrices requires that each of the 2n2 numbers be
     multiplied at some point, leading to a lower bound of Ω(n2 ). No known algorithm can meet
     this bound, and its tightness is unknown.

   • A trivial lower bound for the traveling salesman problem can be obtained as Ω(n2 ) based on
     the number of cities and inter-city distances, but this is not a useful result, as no algorithm
     comes anywhere near this lower bound.

One must take care in deciding how to count. One may think that to search for an element in a
collection, the lower bound would involve looking at every element. That would lead us to a linear
lower bound. But we know that in the case of a sorted array, we can use a binary search and find
the element in logarithmic time. The key lies with the word “must” in the definition of a trivial
lower bound. There is other information in that case (the ordering) that allows us to avoid ever
considering many of the elements.

Information-Theoretic Arguments
Rather than the number of inputs or outputs to process, an information-theoretic lower bound is
based on the amount of information an algorithm needs to produce to achieve its solution.

                                                2
CS 385                                Analysis of Algorithms                           Spring 2011



A binary search fits here – we are trying to find the location of a given value in a sorted array. Since
we know the array is sorted, we can, with each guess, eliminate half of the possible locations of
the goal, resulting in a lower bound (worst case) of log n steps.
Decision trees are a model of an algorithm’s operation that can help us analyze algorithms such as
search and sort that work by comparisons.
In a decision tree, internal nodes represent comparisons and leaves represent outcomes. The tree
branches based on whether the comparison is true or false.
A simple tree for a search for the minimum among 3 numbers can be found in Figure 11.1 of
Levitin.

   • The number of leaves may exceed the number of outcomes if the same result can be obtained
     via different orders of comparisons.

   • The number of leaves must be at least the total number of possible outcomes.

   • The operation of an algorithm on a particular input is modeled by a path from the root to a
     leaf in the decision tree. The number of comparisons is equal to the number of edges along
     that path.

   • Worst-case behavior is determined by the height of the algorithm’s decision tree.

It quickly follows that any such tree with a total of l leaves (outcomes) must have h ≥ ⌈log2 l⌉.
Levitin Figures 11.2 and 11.3 show decision trees for selection and insertion sort of 3 elements.
Our main interest here is to determine a tight lower bound on comparison-based sorting:

   • Any comparison-based sorting algorithm can be represented by a decision tree.

   • The number of leaves (outcomes) must be ≥ n! to account for all possible permutations of
     inputs.

   • The height of binary tree with n! leaves ≥ ⌈log2 n!⌉.

   • This tells us the number of comparisons in the worst case

                                    Cworst (n) ≥ ⌈log2 n!⌉ ≈ n log2 n

      for any comparison-based sorting algorithm.

   • Since we have an algorithm that operates in Θ(n log2 n) (merge sort), this bound is tight.



Adversary Arguments

                                                  3
CS 385                               Analysis of Algorithms                           Spring 2011



Another approach to finding lower bounds is the adversary argument. This method depends on a
“adversary” that makes the algorithm work the hardest by adjusting the input.
For example, when playing a guessing game to determine a number between 1 and n using yes/no
questions (e.g., “is the number less than x?”), the adversary puts the number in the larger of the
two subsets generated by last question. (Yes, it cheats.)
The text also provides an adversary argument to show the lower bound on the number of compar-
isons needed to perform a merge of two sorted n-element lists into a single 2n-element list (as in
merge sort).

Problem Reduction
A key idea in the analysis of algorithms is problem reduction. If we can come up with a way to
convert a problem we wish to solve to an instance of a different problem to which we already have
a solution, this produces a solution to the original problem.
Suppose you wrote a program solving some problem A. A few days later, you find out a program
needs to be written to solve a similar problem B. To avoid writing too much new code, you might
try to come up with a way to solve B using your implementation of A.
So given your input to problem B, you would need to have a procedure to transform this input into
corresponding input to an instance of problem A. Then solve the instance of problem A (which you
already knew how to do). Then you need to transform the output of A back to the corresponding
solution to B.
As a very simple example, suppose you have written a procedure to draw an ellipse.

draw_ellipse(double horiz, double vert, double x, double y)

This procedure deals with trigonometry and works at a low-level with a graphics library. But it
works.
If you are later asked to write a procedure to draw a circle. Hopefully you would quickly realize
that you could make use of your solution to the problem of drawing an ellipse.

draw_circle(double radius, double x, double y) {
  draw_ellipse(2*radius, 2*radius, x, y);
}

So we have transformed or reduced the problem of drawing a circle to the problem of drawing an
ellipse. We can say that draw circle is “not more difficult than”, or “can be transformed in
polynomial time” to draw ellipse.
For a somewhat more interesting example, suppose you are asked to solve the “pairing problem”.
You are given to n-element arrays A1 and A2. Your task is to rearrange the values in A2 such that
the smalled value in A2 is paired with the smallest value in A1. The second smallest in A2 is paired
with the second smallest in A1, and so one. Only values of A2 are rearranged; A1 is unchanged.

                                                 4
CS 385                                Analysis of Algorithms                            Spring 2011



So for the input arrays

A1 23    5 57 45
A2 150 175 100 120

the output would be

A1 23    5 57 45
A2 120 100 175 150

We aren’t concerned about the details of a solution, let’s just assume we have a solution to this
problem. But now, you are asked to solve a different problem. It’s one we know well: sorting an
array A containing n values.
How can we make use of the solution to the pairing problem to solve the sorting problem?
We can transform the sorting problem into an instance of the pairing problem by using the input
array A from the sorting problem as array A2 in the pairing problem, and creating an already-
sorted array (probably just containing the values 1, 2, · · · , n) and using that as A1. Application of
the pairing problem’s solution will result in the sorting of A2, which is exactly what we wanted.
What is the total cost? It’s O(n + T (n) + 1) - where the first n is the time it takes to transform from
the sorting problem to the pairing problem (the construction of A1), T (n) is the cost of computing
the solution to the pairing problem, and 1 (a constant) is the cost of transforming back to a solution
of the sorting problem (which in this case is trivial).
A problem reduction can be used to show a lower bound.

   • If problem A is at least as hard as problem B, then a lower bound for B is also a lower
     bound for A.
   • Hence, we wish to find a problem B with a known lower bound that can be reduced to the
     problem A.

Think about this for a minute and it will make sense: if we know that any solution to a problem
has to have some minimum cost (the lower bound) and we show that some other problem is at least
as hard as that problem, that other problem shares the lower bound of the first.
For example, suppose we wish to find a lower bound for the problem of finding the minimum
spanning tree of a set of points in the plane. This problem, known as the Euclidean MST problem,
is defined as follows: given n points in the plane, construct a tree of minimum total length whose
vertices are the given points.
The problem with the known lower bound we’ll use is the element uniqueness problem (Ω(n log n),
tight).
So our task is to reduce the element uniqueness problem to an instance of the Euclidean MST
problem. We proceed as follows:

                                                  5
CS 385                               Analysis of Algorithms                           Spring 2011



   • If our input to the element uniqueness problem is a set of numbers x1 , x2 , · · · , xn , we can
     transform these to a set of points in the plane by attaching a y-coordinate of 0 to each:
     (x1 , 0), (x2 , 0), · · · , (xn , 0).

   • If we then solve the Euclidean MST problem on this set of input to obtain a spanning tree T .

   • From this, we can obtain a solution to the original element uniqueness problem by checking
     for a 0-length edge.

So we can deduce a lower bound of Ω(n log n) for the Euclidean MST problem.


Tractable Problems, P and N P
A problem is said to be tractable if there exists a polynomial-time (O(p(n)) where p(n) is a poly-
nomial of the input size n) algorithm to solve it.
A problem for which no such algorithm exists is called intractable.
When attempting to determine the tractability of a problem, the answer may be:

   • Yes, it is tractable. This is shown by producing a polynomial-time algorithm.

   • No, it is not tractable. This is done by proof that no algorithm exists or that any algorithm
     must take exponential time.

   • The answer is unknown.

Before we continue, we make a distinction between two problem types: optimization problems
and decision problems.
In an optimization problem, we look to find a solution that maximizes or minimizes some objective
function. For a decision problem, we seek the answer to a yes/no question.
Many problems have both decision and optimization versions. For example, the traveling salesman
problem can be stated either way:

   • optimization: find a Hamiltonian cycle of minimum length.

   • decision: find Hamiltonian cycle of length ≤ m.

Decision problems are more convenient for formal investigation of their complexity and our dis-
cussion that follows will assume decision problems.

P and N P
We define class P as the class of decision problems that are solvable in O(p(n)) time, where p(n)
is a polynomial of problem’s input size n.

                                                 6
CS 385                              Analysis of Algorithms                          Spring 2011



Many of the problems we have seen fall into class P , but do all decision problems fall into this
class?
The answer is no. Some problems are undecidable, such as the famous halting problem. The
problem: given a computer program and an input to it, determine whether the program will halt on
that input or continue working indefinitely on it.
We can prove by contradicion that this problem is undecidable.
Suppose that A is an algorithm that solves the halting problem. More formally, for any program P
and input I, A(P, I) produces a 1 if P halts when executed with input I and 0 if it does not.
Now, take a program P and use the program as its own input. We’ll use the algorithm A to construct
another program Q such that Q(P ) halts if A(P, P ) = 0 (P does not halt on input P ) but does not
halt (goes into a loop) if A(P, P ) = 1 (P halts on input P ).
And finally, we apply Q to itself: Q(Q) halts if A(Q, Q) = 0 (program Q does not halt on Q) and
does not halt if A(Q, Q) = 1 (program Q halts on Q).
Given our construction of the program Q, neither of these outcomes is possible, so no such algo-
rithm A can exist.
There is also a set of problems for which it has been shown to take exponential time to obtain a
solution (with a provable lower bound).
But a larger and important set of problems have no known polynomial-time solution, but there is
no proof that no such solution exists.
We have seen some of these problems:

   • Hamiltonian circuit
   • Traveling salesman
   • Knapsack problem
   • Partition problem
   • Bin packing
   • Graph coloring

For some of these, while there is no known polynomial-time solution, we can easily check if a
given candidate solution is valid. This leads us to..
Class N P (nondeterministic polynomial) is the class of decision problems whose proposed so-
lutions can be verified in polynomial time, i.e., are solvable by a nondeterministic polynomial
algorithm.
A nondeterministic polynomial algorithm is an abstract procedure that:

   1. generates a random string purported to solve the problem

                                                7
CS 385                                Analysis of Algorithms                           Spring 2011



   2. checks whether this solution is correct in polynomial time

By definition, it solves the problem if it is capable of generating and verifying a solution on one of
its tries.
Many decision problems are in N P , including all of those that are in P .
The big open question in theoretical computer science is whether P = N P . What would it mean?
First, one more definition.
A decision problem D is NP-complete if it’s as hard as any problem in N P , i.e.,

   • D is in N P , and

   • every problem in N P is polynomial-time reducible to D

The first requirement isn’t bad – just produce a nondeterministic polynomial algorithm. The sec-
ond, known as the NP-Hard property, is pretty daunting. We’re supposed to show that every
problem in N P is polynomial-time reducible to this problem?
Of course, any N P -complete problems are polynomially reducible to each other, so it suffices to
show that we can reduce any one problem in the set of N P -complete problems to a problem to
show it is N P -complete.
Nonetheless, there are problems known to be N P -complete.
Informally, an N P -complete problem is one for which we have not yet found any O(nc ) algo-
rithms, and if we do find an O(nc ) algorithm to solve it, we’ll then get O(nc ) solutions to all
problems in N P .
Figure 11.6 of Levitin shows the idea graphically.
The first problem shown to be N P -complete was the CNF-satisfiability problem: Is a boolean
expression in its conjunctive normal form (CNF) satisfiable, i.e., are there values of its variables
that makes it true?
For our purposes, we will just note that this problem is in N P by noting this nondeterministic
algorithm:

   1. Guess truth assignment

   2. Substitute the values into the CNF formula to see if it evaluates to true

A check can be done in linear time.
The deterministic solution requires 2n evaluations.
For example, consider the expression:


                                                 8
CS 385                                Analysis of Algorithms                          Spring 2011




                          (A|¬B|¬C)&(A|B)&(¬B|¬D|E)&(¬D|¬E)

We would have to check each of the 25 = 32 combinations of boolean values of A, B, C, D, and
E.
Other problems can be shown to be N P -complete by producing a reduction of CNF-Sat to that
problem. That is, if a problem can be used to solve CNF-Sat, the problem is N P -complete.

Some Famous N P -Complete Problems

   • The Independent Set Problem.
      Input: An undirected graph G and a value k.
      Output: Yes if G has an independent set of size at least k. An independent set is a subset of
      the vertices such that no pair of vertices has an edge between them.
      An algorithm to solve this: Enumerate every possible subset and check if it forms an inde-
      pendent set. Keep track of the largest such subset.
      In the worst case, 2|V | subsets are searched.
      This is the best known solution, but even for a problem with 60 vertices and a computer that
      can do 1 billion subsets per second, it would take 32 years to solve the problem!
      What happens if we move up to 61 vertices?

   • The Hamiltonian Cycle Problem.
      Input: An undirected, weighted graph G = (V, E).
      Output: Yes if G has a Hamiltonian cycle (a cycle that visits every vertex exactly once), no
      otherwise.
      An algorithm to solve this: Enumerate every possible cycle of vertices and check if the edges
      that connect it exist.
      In the worst case, we need to check |V |! paths.
      This is the best known solution, but again for a relatively small problem – 20 vertices, and a
      computer that could do 1 billion permutations per second, again we’re looking at 32 years!
      What happens if we move up to 21 vertices?


So, Does P = N P
Sure, if P = 0 or N = 1. But that’s not helpful.
Most theoretical computer scientists believe that no polynomial time solutions exist for the class
of N P -complete problems.


                                                   9
CS 385                              Analysis of Algorithms                       Spring 2011



There are hundreds of N P -complete problems known, and over 30+ years, no one has found a
polynomial time solution to any of them.
Yet, it remains a central open question in computing.


Dealing with N P -Hard Problems
Realistically, N P -hard problems are “solved” by approximations or stochastic approaches. See
Chapter 12!




                                               10

Más contenido relacionado

La actualidad más candente

CS8451 - Design and Analysis of Algorithms
CS8451 - Design and Analysis of AlgorithmsCS8451 - Design and Analysis of Algorithms
CS8451 - Design and Analysis of AlgorithmsKrishnan MuthuManickam
 
Divide and Conquer - Part 1
Divide and Conquer - Part 1Divide and Conquer - Part 1
Divide and Conquer - Part 1Amrinder Arora
 
design and analysis of algorithm
design and analysis of algorithmdesign and analysis of algorithm
design and analysis of algorithmMuhammad Arish
 
DESIGN AND ANALYSIS OF ALGORITHMS
DESIGN AND ANALYSIS OF ALGORITHMSDESIGN AND ANALYSIS OF ALGORITHMS
DESIGN AND ANALYSIS OF ALGORITHMSGayathri Gaayu
 
01. design & analysis of agorithm intro & complexity analysis
01. design & analysis of agorithm intro & complexity analysis01. design & analysis of agorithm intro & complexity analysis
01. design & analysis of agorithm intro & complexity analysisOnkar Nath Sharma
 
Recursion and Sorting Algorithms
Recursion and Sorting AlgorithmsRecursion and Sorting Algorithms
Recursion and Sorting AlgorithmsAfaq Mansoor Khan
 
CS8451 - Design and Analysis of Algorithms
CS8451 - Design and Analysis of AlgorithmsCS8451 - Design and Analysis of Algorithms
CS8451 - Design and Analysis of AlgorithmsKrishnan MuthuManickam
 
Algorithm chapter 9
Algorithm chapter 9Algorithm chapter 9
Algorithm chapter 9chidabdu
 
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
 
5.5 back tracking 02
5.5 back tracking 025.5 back tracking 02
5.5 back tracking 02Krish_ver2
 
Algorithm in computer science
Algorithm in computer scienceAlgorithm in computer science
Algorithm in computer scienceRiazul Islam
 

La actualidad más candente (20)

CS8451 - Design and Analysis of Algorithms
CS8451 - Design and Analysis of AlgorithmsCS8451 - Design and Analysis of Algorithms
CS8451 - Design and Analysis of Algorithms
 
Divide and Conquer
Divide and ConquerDivide and Conquer
Divide and Conquer
 
Greedy Algorithms
Greedy AlgorithmsGreedy Algorithms
Greedy Algorithms
 
Unit 4
Unit 4Unit 4
Unit 4
 
Divide and Conquer - Part 1
Divide and Conquer - Part 1Divide and Conquer - Part 1
Divide and Conquer - Part 1
 
design and analysis of algorithm
design and analysis of algorithmdesign and analysis of algorithm
design and analysis of algorithm
 
Greedy algorithm
Greedy algorithmGreedy algorithm
Greedy algorithm
 
Divide and conquer
Divide and conquerDivide and conquer
Divide and conquer
 
Unit 2
Unit 2Unit 2
Unit 2
 
DESIGN AND ANALYSIS OF ALGORITHMS
DESIGN AND ANALYSIS OF ALGORITHMSDESIGN AND ANALYSIS OF ALGORITHMS
DESIGN AND ANALYSIS OF ALGORITHMS
 
01. design & analysis of agorithm intro & complexity analysis
01. design & analysis of agorithm intro & complexity analysis01. design & analysis of agorithm intro & complexity analysis
01. design & analysis of agorithm intro & complexity analysis
 
Divide and conquer
Divide and conquerDivide and conquer
Divide and conquer
 
Recursion and Sorting Algorithms
Recursion and Sorting AlgorithmsRecursion and Sorting Algorithms
Recursion and Sorting Algorithms
 
Cis435 week04
Cis435 week04Cis435 week04
Cis435 week04
 
CS8451 - Design and Analysis of Algorithms
CS8451 - Design and Analysis of AlgorithmsCS8451 - Design and Analysis of Algorithms
CS8451 - Design and Analysis of Algorithms
 
Algorithm chapter 9
Algorithm chapter 9Algorithm chapter 9
Algorithm chapter 9
 
36 greedy
36 greedy36 greedy
36 greedy
 
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
 
5.5 back tracking 02
5.5 back tracking 025.5 back tracking 02
5.5 back tracking 02
 
Algorithm in computer science
Algorithm in computer scienceAlgorithm in computer science
Algorithm in computer science
 

Destacado

Sienna 11 graphs
Sienna 11 graphsSienna 11 graphs
Sienna 11 graphschidabdu
 
Sienna 5 decreaseandconquer
Sienna 5 decreaseandconquerSienna 5 decreaseandconquer
Sienna 5 decreaseandconquerchidabdu
 
Sienna 6 bst
Sienna 6 bstSienna 6 bst
Sienna 6 bstchidabdu
 
Sienna 4 divideandconquer
Sienna 4 divideandconquerSienna 4 divideandconquer
Sienna 4 divideandconquerchidabdu
 
Sienna 10 dynamic
Sienna 10 dynamicSienna 10 dynamic
Sienna 10 dynamicchidabdu
 
Sienna 1 intro
Sienna 1 introSienna 1 intro
Sienna 1 introchidabdu
 
Sienna 8 countingsorts
Sienna 8 countingsortsSienna 8 countingsorts
Sienna 8 countingsortschidabdu
 
Sienna 3 bruteforce
Sienna 3 bruteforceSienna 3 bruteforce
Sienna 3 bruteforcechidabdu
 
Sienna 9 hashing
Sienna 9 hashingSienna 9 hashing
Sienna 9 hashingchidabdu
 
Sienna 2 analysis
Sienna 2 analysisSienna 2 analysis
Sienna 2 analysischidabdu
 
Courting Loyalty Template Version
Courting Loyalty Template VersionCourting Loyalty Template Version
Courting Loyalty Template VersionKartik Kompella
 
Sienna 7 heaps
Sienna 7 heapsSienna 7 heaps
Sienna 7 heapschidabdu
 
China Social Game Summit 2010 - Beijing - April 9-10
China Social Game Summit 2010 - Beijing - April 9-10China Social Game Summit 2010 - Beijing - April 9-10
China Social Game Summit 2010 - Beijing - April 9-10AppLeap Inc.
 
Baromètre Mobile Marketing Association France : Déc 2013 - infographie
Baromètre Mobile Marketing Association France : Déc 2013 - infographieBaromètre Mobile Marketing Association France : Déc 2013 - infographie
Baromètre Mobile Marketing Association France : Déc 2013 - infographiePhilippe Dumont
 

Destacado (16)

Sienna 11 graphs
Sienna 11 graphsSienna 11 graphs
Sienna 11 graphs
 
Sienna 5 decreaseandconquer
Sienna 5 decreaseandconquerSienna 5 decreaseandconquer
Sienna 5 decreaseandconquer
 
Sienna 6 bst
Sienna 6 bstSienna 6 bst
Sienna 6 bst
 
Sienna 4 divideandconquer
Sienna 4 divideandconquerSienna 4 divideandconquer
Sienna 4 divideandconquer
 
Sienna 10 dynamic
Sienna 10 dynamicSienna 10 dynamic
Sienna 10 dynamic
 
Sienna 1 intro
Sienna 1 introSienna 1 intro
Sienna 1 intro
 
Sienna 8 countingsorts
Sienna 8 countingsortsSienna 8 countingsorts
Sienna 8 countingsorts
 
Sienna 3 bruteforce
Sienna 3 bruteforceSienna 3 bruteforce
Sienna 3 bruteforce
 
Sienna 9 hashing
Sienna 9 hashingSienna 9 hashing
Sienna 9 hashing
 
Sienna 2 analysis
Sienna 2 analysisSienna 2 analysis
Sienna 2 analysis
 
Courting Loyalty Template Version
Courting Loyalty Template VersionCourting Loyalty Template Version
Courting Loyalty Template Version
 
Jemesouviens
JemesouviensJemesouviens
Jemesouviens
 
Sienna 7 heaps
Sienna 7 heapsSienna 7 heaps
Sienna 7 heaps
 
China Social Game Summit 2010 - Beijing - April 9-10
China Social Game Summit 2010 - Beijing - April 9-10China Social Game Summit 2010 - Beijing - April 9-10
China Social Game Summit 2010 - Beijing - April 9-10
 
Baromètre Mobile Marketing Association France : Déc 2013 - infographie
Baromètre Mobile Marketing Association France : Déc 2013 - infographieBaromètre Mobile Marketing Association France : Déc 2013 - infographie
Baromètre Mobile Marketing Association France : Déc 2013 - infographie
 
Oil & Gas Stormwater Regulation
Oil & Gas Stormwater RegulationOil & Gas Stormwater Regulation
Oil & Gas Stormwater Regulation
 

Similar a Sienna 13 limitations

Analysis and Design of Algorithms notes
Analysis and Design of Algorithms  notesAnalysis and Design of Algorithms  notes
Analysis and Design of Algorithms notesProf. Dr. K. Adisesha
 
Algorithm review
Algorithm reviewAlgorithm review
Algorithm reviewchidabdu
 
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 POWERmuthukrishnavinayaga
 
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 keyappasami
 
Data Structures - Lecture 1 [introduction]
Data Structures - Lecture 1 [introduction]Data Structures - Lecture 1 [introduction]
Data Structures - Lecture 1 [introduction]Muhammad Hammad Waseem
 
Algorithm & data structure lec2
Algorithm & data structure lec2Algorithm & data structure lec2
Algorithm & data structure lec2Abdul Khan
 
Undecidable Problems and Approximation Algorithms
Undecidable Problems and Approximation AlgorithmsUndecidable Problems and Approximation Algorithms
Undecidable Problems and Approximation AlgorithmsMuthu Vinayagam
 
CubeIT Tech - Algorithms
CubeIT Tech - AlgorithmsCubeIT Tech - Algorithms
CubeIT Tech - AlgorithmsKirill Suslov
 
Discrete structure ch 3 short question's
Discrete structure ch 3 short question'sDiscrete structure ch 3 short question's
Discrete structure ch 3 short question'shammad463061
 
Numerical Methods
Numerical MethodsNumerical Methods
Numerical MethodsESUG
 
lecture 9
lecture 9lecture 9
lecture 9sajinsc
 
lecture 1
lecture 1lecture 1
lecture 1sajinsc
 

Similar a Sienna 13 limitations (20)

Unit7
Unit7Unit7
Unit7
 
Daa chapter6
Daa chapter6Daa chapter6
Daa chapter6
 
Analysis and Design of Algorithms notes
Analysis and Design of Algorithms  notesAnalysis and Design of Algorithms  notes
Analysis and Design of Algorithms notes
 
Ada notes
Ada notesAda notes
Ada notes
 
Cis435 week06
Cis435 week06Cis435 week06
Cis435 week06
 
Brute force method
Brute force methodBrute force method
Brute force method
 
Algorithm review
Algorithm reviewAlgorithm review
Algorithm review
 
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
 
Computer Science Exam Help
Computer Science Exam Help Computer Science Exam Help
Computer Science Exam Help
 
Unit 5
Unit 5Unit 5
Unit 5
 
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
 
Data Structures - Lecture 1 [introduction]
Data Structures - Lecture 1 [introduction]Data Structures - Lecture 1 [introduction]
Data Structures - Lecture 1 [introduction]
 
Algorithm & data structure lec2
Algorithm & data structure lec2Algorithm & data structure lec2
Algorithm & data structure lec2
 
Undecidable Problems and Approximation Algorithms
Undecidable Problems and Approximation AlgorithmsUndecidable Problems and Approximation Algorithms
Undecidable Problems and Approximation Algorithms
 
CubeIT Tech - Algorithms
CubeIT Tech - AlgorithmsCubeIT Tech - Algorithms
CubeIT Tech - Algorithms
 
Discrete structure ch 3 short question's
Discrete structure ch 3 short question'sDiscrete structure ch 3 short question's
Discrete structure ch 3 short question's
 
Numerical Methods
Numerical MethodsNumerical Methods
Numerical Methods
 
lecture 9
lecture 9lecture 9
lecture 9
 
lecture 1
lecture 1lecture 1
lecture 1
 
Programming Exam Help
Programming Exam Help Programming Exam Help
Programming Exam Help
 

Más de chidabdu

Sienna 12 huffman
Sienna 12 huffmanSienna 12 huffman
Sienna 12 huffmanchidabdu
 
Unit 3 basic processing unit
Unit 3   basic processing unitUnit 3   basic processing unit
Unit 3 basic processing unitchidabdu
 
Unit 5 I/O organization
Unit 5   I/O organizationUnit 5   I/O organization
Unit 5 I/O organizationchidabdu
 
Algorithm chapter 11
Algorithm chapter 11Algorithm chapter 11
Algorithm chapter 11chidabdu
 
Algorithm chapter 10
Algorithm chapter 10Algorithm chapter 10
Algorithm chapter 10chidabdu
 
Algorithm chapter 8
Algorithm chapter 8Algorithm chapter 8
Algorithm chapter 8chidabdu
 
Algorithm chapter 7
Algorithm chapter 7Algorithm chapter 7
Algorithm chapter 7chidabdu
 
Algorithm chapter 6
Algorithm chapter 6Algorithm chapter 6
Algorithm chapter 6chidabdu
 
Algorithm chapter 5
Algorithm chapter 5Algorithm chapter 5
Algorithm chapter 5chidabdu
 
Algorithm chapter 2
Algorithm chapter 2Algorithm chapter 2
Algorithm chapter 2chidabdu
 
Unit 2 arithmetics
Unit 2   arithmeticsUnit 2   arithmetics
Unit 2 arithmeticschidabdu
 
Unit 1 basic structure of computers
Unit 1   basic structure of computersUnit 1   basic structure of computers
Unit 1 basic structure of computerschidabdu
 
Unit 4 memory system
Unit 4   memory systemUnit 4   memory system
Unit 4 memory systemchidabdu
 

Más de chidabdu (13)

Sienna 12 huffman
Sienna 12 huffmanSienna 12 huffman
Sienna 12 huffman
 
Unit 3 basic processing unit
Unit 3   basic processing unitUnit 3   basic processing unit
Unit 3 basic processing unit
 
Unit 5 I/O organization
Unit 5   I/O organizationUnit 5   I/O organization
Unit 5 I/O organization
 
Algorithm chapter 11
Algorithm chapter 11Algorithm chapter 11
Algorithm chapter 11
 
Algorithm chapter 10
Algorithm chapter 10Algorithm chapter 10
Algorithm chapter 10
 
Algorithm chapter 8
Algorithm chapter 8Algorithm chapter 8
Algorithm chapter 8
 
Algorithm chapter 7
Algorithm chapter 7Algorithm chapter 7
Algorithm chapter 7
 
Algorithm chapter 6
Algorithm chapter 6Algorithm chapter 6
Algorithm chapter 6
 
Algorithm chapter 5
Algorithm chapter 5Algorithm chapter 5
Algorithm chapter 5
 
Algorithm chapter 2
Algorithm chapter 2Algorithm chapter 2
Algorithm chapter 2
 
Unit 2 arithmetics
Unit 2   arithmeticsUnit 2   arithmetics
Unit 2 arithmetics
 
Unit 1 basic structure of computers
Unit 1   basic structure of computersUnit 1   basic structure of computers
Unit 1 basic structure of computers
 
Unit 4 memory system
Unit 4   memory systemUnit 4   memory system
Unit 4 memory system
 

Último

Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 

Último (20)

Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 

Sienna 13 limitations

  • 1. Computer Science 385 Analysis of Algorithms Siena College Spring 2011 Topic Notes: Limitations of Algorithms We conclude with a discussion of the limitations of the power of algorithms. That is, what kinds of problems cannot be solved by any algorithm, or which will require a minimum cost, and what is that minimum cost? Lower Bounds We will first look at lower bounds, which estimate the minimum amount of work needed to solve a given problem. Once we have established a lower bound, we know that no algorithm can exist without performing work equivalent to at least that of the upper bound. Some examples: • the number of comparisons needed to find the largest element in a set of n numbers • number of comparisons needed to sort an array of size n • number of comparisons necessary for searching in a sorted array of n numbers • the number of comparisons needed to determine if all elements of an array of n elements are unique • number of multiplications needed to multiply two n × n matrices Lower bounds may be exact counts or efficiency classes (big Ω). A lower bound is tight if there exists an algorithm with the same efficiency as the lower bound. Some lower bound examples: • sorting: lower bound Ω(n log n), tight • searching in a sorted array: lower bound Ω(log n), tight • determine element uniqueness: lower bound Ω(n log n), tight • n-digit integer multiplication: lower bound Ω(n), tightness unknown • multiplication of n × n matrices: lower bound Ω(n2 ), tightness unknown There are a number of methods that can be used to establish lower bounds:
  • 2. CS 385 Analysis of Algorithms Spring 2011 • trivial lower bounds • information-theoretic arguments (decision trees) • adversary arguments • problem reduction Trivial Lower Bounds Trivial lower bounds are based on counting the number of items that must be processed in input and generated as output to solve a problem. Some examples: • Generating all permutations of a set of n elements has a trivial lower bound of Ω(n!) since all n! permutations must be generated. This lower bound is tight since we have algorithms to do this that operate in Θ(n!). • Evaluating a polynomial p(x) = an xn + an−1 xn−1 + · · · + a0 requires that each of the n ai ’s need to be processed, leading to a lower bound of Ω(n). Again, we have linear algorithms for this, so the bound is tight. • Computing the product of two n × n matrices requires that each of the 2n2 numbers be multiplied at some point, leading to a lower bound of Ω(n2 ). No known algorithm can meet this bound, and its tightness is unknown. • A trivial lower bound for the traveling salesman problem can be obtained as Ω(n2 ) based on the number of cities and inter-city distances, but this is not a useful result, as no algorithm comes anywhere near this lower bound. One must take care in deciding how to count. One may think that to search for an element in a collection, the lower bound would involve looking at every element. That would lead us to a linear lower bound. But we know that in the case of a sorted array, we can use a binary search and find the element in logarithmic time. The key lies with the word “must” in the definition of a trivial lower bound. There is other information in that case (the ordering) that allows us to avoid ever considering many of the elements. Information-Theoretic Arguments Rather than the number of inputs or outputs to process, an information-theoretic lower bound is based on the amount of information an algorithm needs to produce to achieve its solution. 2
  • 3. CS 385 Analysis of Algorithms Spring 2011 A binary search fits here – we are trying to find the location of a given value in a sorted array. Since we know the array is sorted, we can, with each guess, eliminate half of the possible locations of the goal, resulting in a lower bound (worst case) of log n steps. Decision trees are a model of an algorithm’s operation that can help us analyze algorithms such as search and sort that work by comparisons. In a decision tree, internal nodes represent comparisons and leaves represent outcomes. The tree branches based on whether the comparison is true or false. A simple tree for a search for the minimum among 3 numbers can be found in Figure 11.1 of Levitin. • The number of leaves may exceed the number of outcomes if the same result can be obtained via different orders of comparisons. • The number of leaves must be at least the total number of possible outcomes. • The operation of an algorithm on a particular input is modeled by a path from the root to a leaf in the decision tree. The number of comparisons is equal to the number of edges along that path. • Worst-case behavior is determined by the height of the algorithm’s decision tree. It quickly follows that any such tree with a total of l leaves (outcomes) must have h ≥ ⌈log2 l⌉. Levitin Figures 11.2 and 11.3 show decision trees for selection and insertion sort of 3 elements. Our main interest here is to determine a tight lower bound on comparison-based sorting: • Any comparison-based sorting algorithm can be represented by a decision tree. • The number of leaves (outcomes) must be ≥ n! to account for all possible permutations of inputs. • The height of binary tree with n! leaves ≥ ⌈log2 n!⌉. • This tells us the number of comparisons in the worst case Cworst (n) ≥ ⌈log2 n!⌉ ≈ n log2 n for any comparison-based sorting algorithm. • Since we have an algorithm that operates in Θ(n log2 n) (merge sort), this bound is tight. Adversary Arguments 3
  • 4. CS 385 Analysis of Algorithms Spring 2011 Another approach to finding lower bounds is the adversary argument. This method depends on a “adversary” that makes the algorithm work the hardest by adjusting the input. For example, when playing a guessing game to determine a number between 1 and n using yes/no questions (e.g., “is the number less than x?”), the adversary puts the number in the larger of the two subsets generated by last question. (Yes, it cheats.) The text also provides an adversary argument to show the lower bound on the number of compar- isons needed to perform a merge of two sorted n-element lists into a single 2n-element list (as in merge sort). Problem Reduction A key idea in the analysis of algorithms is problem reduction. If we can come up with a way to convert a problem we wish to solve to an instance of a different problem to which we already have a solution, this produces a solution to the original problem. Suppose you wrote a program solving some problem A. A few days later, you find out a program needs to be written to solve a similar problem B. To avoid writing too much new code, you might try to come up with a way to solve B using your implementation of A. So given your input to problem B, you would need to have a procedure to transform this input into corresponding input to an instance of problem A. Then solve the instance of problem A (which you already knew how to do). Then you need to transform the output of A back to the corresponding solution to B. As a very simple example, suppose you have written a procedure to draw an ellipse. draw_ellipse(double horiz, double vert, double x, double y) This procedure deals with trigonometry and works at a low-level with a graphics library. But it works. If you are later asked to write a procedure to draw a circle. Hopefully you would quickly realize that you could make use of your solution to the problem of drawing an ellipse. draw_circle(double radius, double x, double y) { draw_ellipse(2*radius, 2*radius, x, y); } So we have transformed or reduced the problem of drawing a circle to the problem of drawing an ellipse. We can say that draw circle is “not more difficult than”, or “can be transformed in polynomial time” to draw ellipse. For a somewhat more interesting example, suppose you are asked to solve the “pairing problem”. You are given to n-element arrays A1 and A2. Your task is to rearrange the values in A2 such that the smalled value in A2 is paired with the smallest value in A1. The second smallest in A2 is paired with the second smallest in A1, and so one. Only values of A2 are rearranged; A1 is unchanged. 4
  • 5. CS 385 Analysis of Algorithms Spring 2011 So for the input arrays A1 23 5 57 45 A2 150 175 100 120 the output would be A1 23 5 57 45 A2 120 100 175 150 We aren’t concerned about the details of a solution, let’s just assume we have a solution to this problem. But now, you are asked to solve a different problem. It’s one we know well: sorting an array A containing n values. How can we make use of the solution to the pairing problem to solve the sorting problem? We can transform the sorting problem into an instance of the pairing problem by using the input array A from the sorting problem as array A2 in the pairing problem, and creating an already- sorted array (probably just containing the values 1, 2, · · · , n) and using that as A1. Application of the pairing problem’s solution will result in the sorting of A2, which is exactly what we wanted. What is the total cost? It’s O(n + T (n) + 1) - where the first n is the time it takes to transform from the sorting problem to the pairing problem (the construction of A1), T (n) is the cost of computing the solution to the pairing problem, and 1 (a constant) is the cost of transforming back to a solution of the sorting problem (which in this case is trivial). A problem reduction can be used to show a lower bound. • If problem A is at least as hard as problem B, then a lower bound for B is also a lower bound for A. • Hence, we wish to find a problem B with a known lower bound that can be reduced to the problem A. Think about this for a minute and it will make sense: if we know that any solution to a problem has to have some minimum cost (the lower bound) and we show that some other problem is at least as hard as that problem, that other problem shares the lower bound of the first. For example, suppose we wish to find a lower bound for the problem of finding the minimum spanning tree of a set of points in the plane. This problem, known as the Euclidean MST problem, is defined as follows: given n points in the plane, construct a tree of minimum total length whose vertices are the given points. The problem with the known lower bound we’ll use is the element uniqueness problem (Ω(n log n), tight). So our task is to reduce the element uniqueness problem to an instance of the Euclidean MST problem. We proceed as follows: 5
  • 6. CS 385 Analysis of Algorithms Spring 2011 • If our input to the element uniqueness problem is a set of numbers x1 , x2 , · · · , xn , we can transform these to a set of points in the plane by attaching a y-coordinate of 0 to each: (x1 , 0), (x2 , 0), · · · , (xn , 0). • If we then solve the Euclidean MST problem on this set of input to obtain a spanning tree T . • From this, we can obtain a solution to the original element uniqueness problem by checking for a 0-length edge. So we can deduce a lower bound of Ω(n log n) for the Euclidean MST problem. Tractable Problems, P and N P A problem is said to be tractable if there exists a polynomial-time (O(p(n)) where p(n) is a poly- nomial of the input size n) algorithm to solve it. A problem for which no such algorithm exists is called intractable. When attempting to determine the tractability of a problem, the answer may be: • Yes, it is tractable. This is shown by producing a polynomial-time algorithm. • No, it is not tractable. This is done by proof that no algorithm exists or that any algorithm must take exponential time. • The answer is unknown. Before we continue, we make a distinction between two problem types: optimization problems and decision problems. In an optimization problem, we look to find a solution that maximizes or minimizes some objective function. For a decision problem, we seek the answer to a yes/no question. Many problems have both decision and optimization versions. For example, the traveling salesman problem can be stated either way: • optimization: find a Hamiltonian cycle of minimum length. • decision: find Hamiltonian cycle of length ≤ m. Decision problems are more convenient for formal investigation of their complexity and our dis- cussion that follows will assume decision problems. P and N P We define class P as the class of decision problems that are solvable in O(p(n)) time, where p(n) is a polynomial of problem’s input size n. 6
  • 7. CS 385 Analysis of Algorithms Spring 2011 Many of the problems we have seen fall into class P , but do all decision problems fall into this class? The answer is no. Some problems are undecidable, such as the famous halting problem. The problem: given a computer program and an input to it, determine whether the program will halt on that input or continue working indefinitely on it. We can prove by contradicion that this problem is undecidable. Suppose that A is an algorithm that solves the halting problem. More formally, for any program P and input I, A(P, I) produces a 1 if P halts when executed with input I and 0 if it does not. Now, take a program P and use the program as its own input. We’ll use the algorithm A to construct another program Q such that Q(P ) halts if A(P, P ) = 0 (P does not halt on input P ) but does not halt (goes into a loop) if A(P, P ) = 1 (P halts on input P ). And finally, we apply Q to itself: Q(Q) halts if A(Q, Q) = 0 (program Q does not halt on Q) and does not halt if A(Q, Q) = 1 (program Q halts on Q). Given our construction of the program Q, neither of these outcomes is possible, so no such algo- rithm A can exist. There is also a set of problems for which it has been shown to take exponential time to obtain a solution (with a provable lower bound). But a larger and important set of problems have no known polynomial-time solution, but there is no proof that no such solution exists. We have seen some of these problems: • Hamiltonian circuit • Traveling salesman • Knapsack problem • Partition problem • Bin packing • Graph coloring For some of these, while there is no known polynomial-time solution, we can easily check if a given candidate solution is valid. This leads us to.. Class N P (nondeterministic polynomial) is the class of decision problems whose proposed so- lutions can be verified in polynomial time, i.e., are solvable by a nondeterministic polynomial algorithm. A nondeterministic polynomial algorithm is an abstract procedure that: 1. generates a random string purported to solve the problem 7
  • 8. CS 385 Analysis of Algorithms Spring 2011 2. checks whether this solution is correct in polynomial time By definition, it solves the problem if it is capable of generating and verifying a solution on one of its tries. Many decision problems are in N P , including all of those that are in P . The big open question in theoretical computer science is whether P = N P . What would it mean? First, one more definition. A decision problem D is NP-complete if it’s as hard as any problem in N P , i.e., • D is in N P , and • every problem in N P is polynomial-time reducible to D The first requirement isn’t bad – just produce a nondeterministic polynomial algorithm. The sec- ond, known as the NP-Hard property, is pretty daunting. We’re supposed to show that every problem in N P is polynomial-time reducible to this problem? Of course, any N P -complete problems are polynomially reducible to each other, so it suffices to show that we can reduce any one problem in the set of N P -complete problems to a problem to show it is N P -complete. Nonetheless, there are problems known to be N P -complete. Informally, an N P -complete problem is one for which we have not yet found any O(nc ) algo- rithms, and if we do find an O(nc ) algorithm to solve it, we’ll then get O(nc ) solutions to all problems in N P . Figure 11.6 of Levitin shows the idea graphically. The first problem shown to be N P -complete was the CNF-satisfiability problem: Is a boolean expression in its conjunctive normal form (CNF) satisfiable, i.e., are there values of its variables that makes it true? For our purposes, we will just note that this problem is in N P by noting this nondeterministic algorithm: 1. Guess truth assignment 2. Substitute the values into the CNF formula to see if it evaluates to true A check can be done in linear time. The deterministic solution requires 2n evaluations. For example, consider the expression: 8
  • 9. CS 385 Analysis of Algorithms Spring 2011 (A|¬B|¬C)&(A|B)&(¬B|¬D|E)&(¬D|¬E) We would have to check each of the 25 = 32 combinations of boolean values of A, B, C, D, and E. Other problems can be shown to be N P -complete by producing a reduction of CNF-Sat to that problem. That is, if a problem can be used to solve CNF-Sat, the problem is N P -complete. Some Famous N P -Complete Problems • The Independent Set Problem. Input: An undirected graph G and a value k. Output: Yes if G has an independent set of size at least k. An independent set is a subset of the vertices such that no pair of vertices has an edge between them. An algorithm to solve this: Enumerate every possible subset and check if it forms an inde- pendent set. Keep track of the largest such subset. In the worst case, 2|V | subsets are searched. This is the best known solution, but even for a problem with 60 vertices and a computer that can do 1 billion subsets per second, it would take 32 years to solve the problem! What happens if we move up to 61 vertices? • The Hamiltonian Cycle Problem. Input: An undirected, weighted graph G = (V, E). Output: Yes if G has a Hamiltonian cycle (a cycle that visits every vertex exactly once), no otherwise. An algorithm to solve this: Enumerate every possible cycle of vertices and check if the edges that connect it exist. In the worst case, we need to check |V |! paths. This is the best known solution, but again for a relatively small problem – 20 vertices, and a computer that could do 1 billion permutations per second, again we’re looking at 32 years! What happens if we move up to 21 vertices? So, Does P = N P Sure, if P = 0 or N = 1. But that’s not helpful. Most theoretical computer scientists believe that no polynomial time solutions exist for the class of N P -complete problems. 9
  • 10. CS 385 Analysis of Algorithms Spring 2011 There are hundreds of N P -complete problems known, and over 30+ years, no one has found a polynomial time solution to any of them. Yet, it remains a central open question in computing. Dealing with N P -Hard Problems Realistically, N P -hard problems are “solved” by approximations or stochastic approaches. See Chapter 12! 10