Cliff Shaffer Computer Science Computational Complexity.

Slides:



Advertisements
Similar presentations
NP-Complete Problems CIT 596, Spring Problems that Cross the Line What if a problem has: o An exponential upper bound o A polynomial lower bound.
Advertisements

The Theory of NP-Completeness
CPE702 Complexity Classes Pruet Boonma Department of Computer Engineering Chiang Mai University Based on Material by Jenny Walter.
Computational problems, algorithms, runtime, hardness
CSE332: Data Abstractions Lecture 27: A Few Words on NP Dan Grossman Spring 2010.
Complexity Theory CSE 331 Section 2 James Daly. Reminders Project 4 is out Due Friday Dynamic programming project Homework 6 is out Due next week (on.
2 -1 Chapter 2 The Complexity of Algorithms and the Lower Bounds of Problems.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 21 Instructor: Paul Beame.
DAST, Spring © L. Joskowicz 1 Data Structures – LECTURE 1 Introduction Motivation: algorithms and abstract data types Easy problems, hard problems.
Eleg667/2001-f/Topic-1a 1 A Brief Review of Algorithm Design and Analysis.
The Theory of NP-Completeness
CSE 326: Data Structures NP Completeness Ben Lerner Summer 2007.
Algorithms. Problems, Algorithms, Programs Problem - a well defined task. –Sort a list of numbers. –Find a particular item in a list. –Find a winning.
Analysis of Algorithms CS 477/677
Chapter 11: Limitations of Algorithmic Power
Chapter 11 Limitations of Algorithm Power Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
DAST, Spring © L. Joskowicz 1 Data Structures – LECTURE 1 Introduction Motivation: algorithms and abstract data types Easy problems, hard problems.
1.1 Chapter 1: Introduction What is the course all about? Problems, instances and algorithms Running time v.s. computational complexity General description.
1 Complexity Lecture Ref. Handout p
Programming & Data Structures
Chapter 11 Limitations of Algorithm Power. Lower Bounds Lower bound: an estimate on a minimum amount of work needed to solve a given problem Examples:
Computational Complexity Polynomial time O(n k ) input size n, k constant Tractable problems solvable in polynomial time(Opposite Intractable) Ex: sorting,
1 The Theory of NP-Completeness 2012/11/6 P: the class of problems which can be solved by a deterministic polynomial algorithm. NP : the class of decision.
1 Growth of Functions CS 202 Epp, section ??? Aaron Bloomfield.
Nattee Niparnan. Easy & Hard Problem What is “difficulty” of problem? Difficult for computer scientist to derive algorithm for the problem? Difficult.
Complexity Classes (Ch. 34) The class P: class of problems that can be solved in time that is polynomial in the size of the input, n. if input size is.
1 Ethics of Computing MONT 113G, Spring 2012 Session 13 Limits of Computer Science.
Tonga Institute of Higher Education Design and Analysis of Algorithms IT 254 Lecture 8: Complexity Theory.
Algorithms  Al-Khwarizmi, arab mathematician, 8 th century  Wrote a book: al-kitab… from which the word Algebra comes  Oldest algorithm: Euclidian algorithm.
Analyzing algorithms & Asymptotic Notation BIO/CS 471 – Algorithms for Bioinformatics.
Problems you shouldn’t tackle. Problem Complexity.
TECH Computer Science NP-Complete Problems Problems  Abstract Problems  Decision Problem, Optimal value, Optimal solution  Encodings  //Data Structure.
CSC 413/513: Intro to Algorithms NP Completeness.
CSC 172 P, NP, Etc. “Computer Science is a science of abstraction – creating the right model for thinking about a problem and devising the appropriate.
Complexity Non-determinism. NP complete problems. Does P=NP? Origami. Homework: continue on postings.
1 Lower Bounds Lower bound: an estimate on a minimum amount of work needed to solve a given problem Examples: b number of comparisons needed to find the.
1 The Theory of NP-Completeness 2 Cook ’ s Theorem (1971) Prof. Cook Toronto U. Receiving Turing Award (1982) Discussing difficult problems: worst case.
Erdal Kose CC30.10 These slides are based of Prof. N. Yanofsky Lecture notes.
NP-Complete Problems. Running Time v.s. Input Size Concern with problems whose complexity may be described by exponential functions. Tractable problems.
1 Chapter 34: NP-Completeness. 2 About this Tutorial What is NP ? How to check if a problem is in NP ? Cook-Levin Theorem Showing one of the most difficult.
NP-COMPLETE PROBLEMS. Admin  Two more assignments…  No office hours on tomorrow.
NP-Complete problems.
Limits to Computation How do you analyze a new algorithm? –Put it in the form of existing algorithms that you know the analysis. –For example, given 2.
Module #7: Algorithmic Complexity Rosen 5 th ed., §2.3.
CS 3343: Analysis of Algorithms Lecture 25: P and NP Some slides courtesy of Carola Wenk.
Optimization Problems
Complexity & Computability. Limitations of computer science  Major reasons useful calculations cannot be done:  execution time of program is too long.
2101INT – Principles of Intelligence Systems Lecture 3.
Week 13 - Monday.  What did we talk about last time?  B-trees  Hamiltonian tour  Traveling Salesman Problem.
David Evans CS200: Computer Science University of Virginia Computer Science Lecture 15: Intractable Problems (Smiley.
LIMITATIONS OF ALGORITHM POWER
CPS Computational problems, algorithms, runtime, hardness (a ridiculously brief introduction to theoretical computer science) Vincent Conitzer.
CS6045: Advanced Algorithms NP Completeness. NP-Completeness Some problems are intractable: as they grow large, we are unable to solve them in reasonable.
Complexity © 2014 Project Lead The Way, Inc.Computer Science and Software Engineering.
CS 461 – Nov. 18 Section 7.1 Overview of complexity issues –“Can quickly decide” vs. “Can quickly verify” Measuring complexity Dividing decidable languages.
CompSci On the Limits of Computing  Reasons for Failure 1. Runs too long o Real time requirements o Predicting yesterday's weather 2. Non-computable.
Lecture. Today Problem set 9 out (due next Thursday) Topics: –Complexity Theory –Optimization versus Decision Problems –P and NP –Efficient Verification.
Copyright © 2014 Curt Hill Algorithm Analysis How Do We Determine the Complexity of Algorithms.
1 Computability Tractable, Intractable and Non-computable functions.
David Evans CS200: Computer Science University of Virginia Computer Science Lecture 23: Intractable Problems (Smiley Puzzles.
1 The Theory of NP-Completeness 2 Review: Finding lower bound by problem transformation Problem X reduces to problem Y (X  Y ) iff X can be solved by.
CS 154 Formal Languages and Computability May 10 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron Mak.
The NP class. NP-completeness Lecture2. The NP-class The NP class is a class that contains all the problems that can be decided by a Non-Deterministic.
CS 2210 Discrete Structures Algorithms and Complexity
Discrete Mathematics CS 2610
Chapter 11 Limitations of Algorithm Power
NP-Complete Problems.
CSC 380: Design and Analysis of Algorithms
Algorithms CSCI 235, Spring 2019 Lecture 36 P vs
CS 2210 Discrete Structures Algorithms and Complexity
Presentation transcript:

Cliff Shaffer Computer Science Computational Complexity

Computer Performance

Do we need to care about performance when computers keep getting faster?

Computer Performance Do we need to care about performance when computers keep getting faster? Our history is to do bigger problems, not the same ones faster.

Computer Performance Do we need to care about performance when computers keep getting faster? Our history is to do bigger problems, not the same ones faster. More complex problems are less tied to our everyday “common sense” experience

Algorithm Analysis We could compare two programs by running them side-by-side

Algorithm Analysis We could compare two programs by running them side-by-side But that means we have to implement them!

Algorithm Analysis We could compare two programs by running them side-by-side But that means we have to implement them! We want a way to easily evaluate programs before they are written Look at the algorithm, not the program

Algorithm Analysis We could compare two programs by running them side-by-side But that means we have to implement them! We want a way to easily evaluate programs before they are written Look at the algorithm, not the program Algorithm Analysis estimates problem cost as a function of growth rate

Simple Search Find the record with key value Sequential search: Look through each record in turn. If there are n records, we do work proportional to n (unless we are lucky).

Simple Search Find the record with key value Sequential search: Look through each record in turn. If there are n records, we do work proportional to n (unless we are lucky). The growth rate of this problem (in the average or worst cases) is linear on n.

Sorting: Insertion Sort For each record Insert it into the sorted list made from the records already seen. Might have to look at each such record already in the (sorted) list – n work. Since we do this for n records, this is n*n in the worst (and average) cases. So the cost is proportional to n 2 (unless we are really lucky).

Sorting: Merge Sort For a list of n records: Split the list in half. Merge each half (using merge sort) ‏ Merge the records together (needs n work) ‏ Total cost: proportional to n log n

Sorting Demo URL: Compare Insertion, Shell, Heap, Quick sorts

Does It Matter? 1000 records: Insertion sort: 1,000,000 Mergesort: 10,000 Factor of 100 difference 1,000,000 records Insertion sort: 1,000,000,000,000 Mergsort: 20,000,000 Factor of 50,000 difference Hours vs. seconds on a real computer

Tractable vs. Intractable Cost n is better than cost n log n, which is better than cost n 2.

Tractable vs. Intractable Cost n is better than cost n log n, which is better than cost n 2. These are all polynomial: a faster computer gives you a bigger problem in an hour by some factor.

Tractable vs. Intractable Cost n is better than cost n log n, which is better than cost n 2. These are all polynomial: a faster computer gives you a bigger problem in an hour by some factor. Exponential growth: 2 n.

Tractable vs. Intractable Cost n is better than cost n log n, which is better than cost n 2. These are all polynomial: a faster computer gives you a bigger problem in an hour by some factor. Exponential growth: 2 n. Making input one unit bigger doubles the cost.

Tractable vs. Intractable Cost n is better than cost n log n, which is better than cost n 2. These are all polynomial: a faster computer gives you a bigger problem in an hour by some factor. Exponential growth: 2 n. Making input one unit bigger doubles the cost. Running twice as fast only gives you one more problem unit.

Tractable vs. Intractable Cost n is better than cost n log n, which is better than cost n 2. These are all polynomial: a faster computer gives you a bigger problem in an hour by some factor. Exponential growth: 2 n. Making input one unit bigger doubles the cost. Running twice as fast only gives you one more problem unit. Exponential-time algorithms are “intractable”.

Problems Problems have many algorithms (sorting) ‏ What does “cost of a problem” mean?

Problems Problems have many algorithms (sorting) ‏ What does “cost of a problem” mean? We say the problem’s cost is that of the best algorithm. But we can’t know all the algorithms!

Problems Problems have many algorithms (sorting) ‏ What does “cost of a problem” mean? We say the problem’s cost is that of the best algorithm. But we can’t know all the algorithms! It is possible (though difficult) to figure out lowest cost for any algorithm to solve the problem Sorting: n log n lower bound.

Traveling Salesman Problem Given n cities, find a tour for all the cities that is of shortest length.

Traveling Salesman Problem Given n cities, find a tour for all the cities that is of shortest length. Nobody knows a polynomial-time algorithm, only exponential algorithms.

Traveling Salesman Problem Given n cities, find a tour for all the cities that is of shortest length. Nobody knows a polynomial-time algorithm, only exponential algorithms. We don’t KNOW that this problem needs exponential time.

Traveling Salesman Example URL: Nearest Neighbor Heuristic

NP-Completeness Many, many problems are like traveling salesman – we know no polynomial algorithm, and have no proof they need exponential time.

NP-Completeness Many, many problems are like traveling salesman – we know no polynomial algorithm, and have no proof they need exponential time. It is possible to “cheaply” convert any problem from this collection into any other.

NP-Completeness Many, many problems are like traveling salesman – we know no polynomial algorithm, and have no proof they need exponential time. It is possible to “cheaply” convert any problem from this collection into any other. So if we had a polynomial time algorithm for any of them, we’d have one for all.

NP-Completeness Many, many problems are like traveling salesman – we know no polynomial algorithm, and have no proof they need exponential time. It is possible to “cheaply” convert any problem from this collection into any other. So if we had a polynomial time algorithm for any of them, we’d have one for all. These are called NP-complete problems.

NP-Completeness Many, many problems are like traveling salesman – we know no polynomial algorithm, and have no proof they need exponential time. It is possible to “cheaply” convert any problem from this collection into any other. So if we had a polynomial time algorithm for any of them, we’d have one for all. These are called NP-complete problems. NP problems are those problems for which we can quickly verify that a proposed solution is correct.

Examples of NP-complete problems Find the cheapest way to wire up telephones in a city Find the largest clique in a graph Find a way to assign values to a boolean expression to make it true Find the largest matching between workers and compatible jobs Find the least number of boxes needed to pack some goods

What do you do? … when you must solve an NP-complete problem?

What do you do? … when you must solve an NP-complete problem? Approximation Optimization

What do you do? … when you must solve an NP-complete problem? Approximation Optimization Many engineering problems are optimization problems

What do you do? … when you must solve an NP-complete problem? Approximation Optimization Many engineering problems are optimization problems Examples: Aircraft design, “best” decision

Why is optimization hard? Imagine a 2d problem – find the highest hill.

Why is optimization hard? Imagine a 2d problem – find the highest hill. Imagine a 10-parameter problem Just checking the “high” and “low” values would give 1024 combinations.

Why is optimization hard? Imagine a 2d problem – find the highest hill. Imagine a 10-parameter problem Just checking the “high” and “low” values would give 1024 combinations. Imagine a 10d “cube”… 1024 corners. The goal is to find the best point in the cube, for a complex function.

Why is optimization hard? Imagine a 2d problem – find the highest hill. Imagine a 10-parameter problem Just checking the “high” and “low” values would give 1024 combinations. Imagine a 10d “cube”… 1024 corners. The goal is to find the best point in the cube, for a complex function. Many problems have higher dimension

Why is optimization hard? Imagine a 2d problem – find the highest hill. Imagine a 10-parameter problem Just checking the “high” and “low” values would give 1024 combinations. Imagine a 10d “cube”… 1024 corners. The goal is to find the best point in the cube, for a complex function. Many problems have higher dimension Whole branches of CS/Math/Engineering devoted to optimization

Uncomputable Problems Not all problems that we can think of can be solved. Abstractly, not all functions can be computed.

Uncomputable Problems Not all problems that we can think of can be solved. Abstractly, not all functions can be computed. The number of computable programs is countably infinite. The number of integer functions is uncountably infinite.

The Halting Problem Problem: Given a particular program P on particular input I, does P halt when run on I?

The Halting Problem Problem: Given a particular program P on particular input I, does P halt when run on I? Can be proved that this is impossible to determine in all cases.

The Halting Problem Problem: Given a particular program P on particular input I, does P halt when run on I? Can be proved that this is impossible to determine in all cases. Lots of problems like this that try to determine program behavior.

The Halting Problem Problem: Given a particular program P on particular input I, does P halt when run on I? Can be proved that this is impossible to determine in all cases. Lots of problems like this that try to determine program behavior. Does this program contain a virus?

Does this terminate for all n? (n is an integer) ‏ While n > 1 do if Odd(n) then n = 3n + 1 else n = n/2