Download presentation
Presentation is loading. Please wait.
Published byFarida Widya Sudjarwadi Modified over 5 years ago
1
Algorithms CSCI 235, Spring 2019 Lecture 36 P vs
Algorithms CSCI 235, Spring 2019 Lecture 36 P vs. NP Non Computable Functions 1
2
Computational Complexity
Computational complexity measures the difficulty of a problem with respect to the length of the input. If you can show that a given problem is computationally difficult then it makes no sense to try to develop a fast algorithm to solve it. Instead one might spend time trying to find a good approximate solution or to use tools for solving computationally difficult problems.
3
Tractable problems We can classify problems according to their running times: Median index of an array: Search in a sorted array (binary search): kth smallest element of an array (order statistics): Comparison-based sort: Matrix-chain multiplication: These are bounded by polynomials (nk). Problems whose growth rate is given by a polynomial function is are tractable problems. Tractable problems run in a reasonable amount of time. O(1) O(lgn) O( n) O(nlgn) O(n3)
4
The class P P consists of decision problems (yes/no problems) where an algorithm exists that determines if a given instance is a yes or a no instance in polynomial time with respect to the size of the input. P is robust in that it is the same class for all reasonable computational models and all reasonable encodings. P roughly corresponds to the class of problems that are realistically solvable on a computer. In complexity theory, we often disregard polynomial differences. This does not mean that those differences are not important!
5
Intractable Problems Intractable algorithms run in super-polynomial time, e.g. exponential time (2n). Example: Exhaustive computation of matrix-chain multiplication took exponential time (W(4n/n3/2)). Fortunately, there is a more efficient algorithm that runs in polynomial time: n3 .
6
Problems with no known efficient solution
Are there problems for which there is no known more efficient solution? Yes Example: Find the longest acyclic path from vertex x to vertex y in graph G. No faster solution known than checking all possible paths. This takes n! time. (Note: We can find the shortest path in polynomial time. How?) How long is long? Suppose an algorithm has growth rate of 2n. How long will it take to run it on an input size of n = 100?
7
P vs. NP P: Set of all decision problems that can be solved in polynomial time. NP: Set of all decision problems that can be verified in polynomial time. Any problem in P is also in NP. Are there problems in NP that are not in P? The answer is not known! NP-Complete problems: Special class of NP problems. If you can show that you can solve any NP-Complete problem in polynomial time, then you can solve all NP problems in polynomial time!
8
Definition of NP NP is the class of problems that have polynomial-time verifiers. Note that NP stands for nondeterministic polynomial time. It is known that P ⊆ NP ⊆ EXPTIME and that P ≠ EXPTIME. That is, that there are problems that provably need exponential time. It is not known whether or not P = NP. It is also not known whether or not NP = EXPTIME. The P = NP problem is the most important open problem in theoretical computer science. The classes are strongly believed to be different. Example: The Travelling Salesman Problem-- Given a set of n cities and distances between each city, does there exist a route shorter than m that visits each city once, starting and stopping at home. How long does it take? This problem is NP Complete.
9
Other NP-Complete Problems
10
Non-Computable Functions
In this course we have discussed: Algorithmic approaches to solving problems Ways to make algorithms more efficient Intractable problems--A limitation of CS One more important topic: Noncomputable functions (Another limitation of CS): These are functions for which there cannot be a computer program to solve them.
11
Countability To prove that noncomputable functions exist, we must use the concept of countable and uncountable sets. A set of elements is countable if, loosely speaking, every element can systematically be matched 1 to 1 with a positive integer. Examples of countable sets: Positive integers; Positive and negative integers All strings of printable characters. (Includes all possible computer programs). A set is uncountable if, loosely speaking, you cannot match up all the elements in a 1 to 1 manner with the positive integers. There will always be some elements that you miss. Example: The set of all functions that accept an integer input and return an integer output.
12
Existence of Noncomputable Functions
The set of all possible programs is countable. The set of all possible functions is uncountable. Therefore, if we try to match up each function with a program that computes it, we will always leave some functions out. These left-over functions are noncomputable. Next time: We will prove noncomputability for a particular problem.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.