SlideShare a Scribd company logo
Computability
Tractable, Intractable and
Non-computable functions
(C) 2010 Thomas J Cortina, Carnegie Mellon University
Efficiency
●A computer program should be totally correct, but
it should also
oexecute as quickly as possible (time-efficiency)
ouse memory wisely (storage-efficiency)
●How do we compare programs (or algorithms in
general) with respect to execution time?
ovarious computers run at different speeds due to different
processors
ocompilers optimize code before execution
othe same algorithm can be written differently depending on the
programming language used
(C) 2010 Thomas J Cortina, Carnegie Mellon University
Order of Complexity
●For very large n, we express the number of operations
as the order of complexity.
●Order of complexity for worst-case behavior is often
expressed using Big-O notation:
Number of operations Order of Complexity
n O(n)
n/2 + 6 O(n)
2n + 9 O(n)
Usually doesn't
matter what the
constants are...
we are only
concerned about
the highest power
of n.(C) 2010 Thomas J Cortina, Carnegie Mellon University
O(n) ("Linear")
n
(amount of data)
Number of
Operations
n
n/2 + 6
2n + 9
(C) 2010 Thomas J Cortina, Carnegie Mellon University
Order of Complexity
Number of operations Order of Complexity
n2 O(n2)
2n2 + 7 O(n2)
n2/2 + 5n + 2 O(n2)
Usually doesn't
matter what the
constants are...
we are only
concerned about
the highest power
of n.
(C) 2010 Thomas J Cortina, Carnegie Mellon University
O(n2) ("Quadratic")
n
(amount of data)
Number of
Operations
n2/2 + 5n + 22n2 + 7
n2
(C) 2010 Thomas J Cortina, Carnegie Mellon University
Order of Complexity
Number of operations Order of Complexity
log2n O(log n)
log10n O(log n)
2(log2n) + 5 O(log n)
The logarithm base
is not written in
big O notation
since all that matters
is that the function
is logarithmic.
(C) 2010 Thomas J Cortina, Carnegie Mellon University
O(log n) ("Logarithmic")
n
(amount of data)
Number of
Operations
log2 n
log10 n
2(log2 n) + 5
(C) 2010 Thomas J Cortina, Carnegie Mellon University
Comparing Big O Functions
n
(amount of data)
Number of
Operations
O(2n)
O(1)
O(n log n)
O(log n)
O(n2)
O(n)
(C) 2010 Thomas J Cortina, Carnegie Mellon University
Searching & Sorting
WORST CASE Order Of Complexity on N data elements
●Linear Search O(N)
●Binary Search O(log N)
●Selection Sort O(N2)
●Bubble Sort O(N2)
●Merge Sort O(N log N)
●Quick Sort O(N2)
●Sort + Binary Search O(N log N) + O(log N)
= O(N log N)
(C) 2010 Thomas J Cortina, Carnegie Mellon University
Comparing Algorithms
●Assume an algorithm processes n data values. If each
operation takes 1 s to execute, how many s will it take
to run the algorithm on 100 data values if the algorithm
has the following number of computations?
Number of Computations Execution Time
n 100 s
n • log2 n 665 s
n2 10,000 s
n3 1,000,000 s = 1 sec
2n > 1030 s
n! > 10160 s
(C) 2010 Thomas J Cortina, Carnegie Mellon University
Decision Problems
●A specific set of computations are classified as
decision problems.
●An algorithm describes a decision problem if its
output is simply YES or NO, depending on
whether a certain property holds for its input.
●Example:
Given a set of n shapes,
can these shapes be
arranged into a rectangle?
(C) 2010 Thomas J Cortina, Carnegie Mellon University
Monkey Puzzle Problem
●Given:
oA set of n square cards whose sides are imprinted with
the upper and lower halves of colored monkeys.
on is a square number, such that n = m2.
oCards cannot be rotated.
●Problem:
oDetermine if an arrangement of the n cards in an
m X m grid exists such that each adjacent pair of cards
display the upper and lower half of a monkey of the
same color.
Source: www.dwheeler.com (2002)(C) 2010 Thomas J Cortina, Carnegie Mellon University
Example
Images from: Simonas Šaltenis, Aalborg University, simas@cs.auc.dk
1
2
3
4
5
6
7
8
9
(C) 2010 Thomas J Cortina, Carnegie Mellon University
Analysis
Simple algorithm:
●Pick one card for each cell of m X m grid.
●Verify if each pair of touching edges make a full
monkey of the same color.
●If not, try another arrangement until a solution is
found or all possible arrangements are checked.
●Answer "YES" if a solution is found. Otherwise,
answer "NO" if all arrangements are analyzed and
no solution is found.
(C) 2010 Thomas J Cortina, Carnegie Mellon University
Analysis
If there are n = 9 cards (m = 3):
To fill the first cell, we have 9 card choices.
To fill the second cell, we have 8 card
choices left.
To fill the third cell, we have 7 card choices
remaining.
etc.The total number of unique arrangements for n = 9 cards is:
9 * 8 * 7 * 6 * 5 * 4 * 3 * 2 * 1 = 362,880
(C) 2010 Thomas J Cortina, Carnegie Mellon University
Analysis
For n cards, the number of arrangements to examine is
n! (n factorial)
If we can analyze one arrangement in a microsecond:
n Time to analyze all arrangements
9 362,880 s = 0.36288 s
16 20,922,789,888,000 s
≈ 242 days
25 15,511,210,043,330,985,984,000,000 s
≈ 491,520,585,955 years(C) 2010 Thomas J Cortina, Carnegie Mellon University
Map Coloring
●Given a map of n territories, can the map be
colored using k colors such that no two
adjacent territories are colored with the same
color?
●k=4: Answer is always yes.
●k=2: Only if the map contains no point that is
the junction of an odd number of territories.
(C) 2010 Thomas J Cortina, Carnegie Mellon University
Map Coloring
(C) 2010 Thomas J Cortina, Carnegie Mellon University
Map Coloring
●Given a map of 48 territories, can the map be colored
using 3 colors such that no two adjacent territories are
colored with the same color?
oPick a color for California (3 choices)
oPick a color for Nevada (3 choices)
o...
●There are 348 = 79,766,443,076,872,509,863,361
possible colorings.
●No one has come up with a better algorithmic solution
that works in general for any map, so far.(C) 2010 Thomas J Cortina, Carnegie Mellon University
Classifications
●Algorithms that are O(nk) for some
fixed k are polynomial-time algorithms.
oO(1), O(log n), O(n), O(n log n), O(n2)
oreasonable, tractable
●All other algorithms are super-polynomial-
time algorithms.
oO(2n), O(n!), O(nn)
ounreasonable, intractable
(C) 2010 Thomas J Cortina, Carnegie Mellon University
Traveling Salesperson
●Given: a weighted graph of nodes
representing cities and edges representing
flight paths (weights represent cost)
●Is there a route that takes the salesperson
through every city and back to the starting
city with cost no more than k?
oThe salesperson can visit a city only once (except
for the start and end of the trip).
(C) 2010 Thomas J Cortina, Carnegie Mellon University
Traveling Salesperson
A
B
D
C
G
E
F
12
6
4
5
9
8
10
7 11
3
7
7
Is there a route with cost at most 52? YES (Route above costs 50.)
Is there a route with cost at most 48? YES? NO?
(C) 2010 Thomas J Cortina, Carnegie Mellon University
Traveling Salesperson
●If there are n cities, what is the maximum number of
routes that we might need to compute?
●Worst-case: There is a flight available between
every pair of cities.
●Compute cost of every possible route.
oPick a starting city
oPick the next city (n-1 choices remaining)
oPick the next city (n-2 choices remaining)
o...
●Maximum number of routes: (n-1)! = O(n!)
how to
build
a
route
(C) 2010 Thomas J Cortina, Carnegie Mellon University
P and NP
●The class P consists of all those decision problems
that can be solved on a deterministic sequential
machine (e.g. a computer) in an amount of time that
is polynomial with respect to the size of the input
●The class NP consists of all those decision problems
whose positive solutions can be verified in
polynomial time given the right information.
from Wikipedia
(C) 2010 Thomas J Cortina, Carnegie Mellon University
NP Complete
●The class NPC consists of all those problems in NP
that are least likely to be in P.
oEach of these problems is called NP Complete.
oMonkey puzzle, Traveling salesperson, Hamiltonian path,
map coloring, satisfiability are all in NPC.
●Every problem in NPC can be transformed to another
problem in NPC.
oIf there were some way to solve one of these problems in
polynomial time, we should be able to solve all of these
problems in polynomial time.
(C) 2010 Thomas J Cortina, Carnegie Mellon University
Complexity Classes
NP Problems
P Problems
NP Complete
Problems
But does P = NP?
If P ≠ NP, then all decision problems can be broken
down into this classification scheme.
If P = NP, then all three classes are one and the same.
The Clay Mathematics Institute is offering a $1M prize
for the first person to prove P = NP or P ≠ NP.
(http://www.claymath.org/millennium/P_vs_NP/)
We know that P < NP, since
any problem that can be solved
in polynomial time can certainly
have a solution verified in
polynomial time.
(C) 2010 Thomas J Cortina, Carnegie Mellon University
(C) 2010 Thomas J Cortina, Carnegie Mellon University
It gets worse...
●Tractable Problems
oProblems that have reasonable, polynomial-time
solutions
●Intractable Problems
oProblems that have no reasonable, polynomial-time
solutions
●Noncomputable Problems
oProblems that have no algorithms at all to solve
them
(C) 2010 Thomas J Cortina, Carnegie Mellon University
Noncomputability and
Undecidability
●An algorithmic problem that has no algorithm is
called noncomputable.
●If the noncomputable algorithm requires a yes/no
answer, the problem is called undecidable.
●Example:
oGiven any set of any number of different tile designs
(examples shown above), with an infinite number of
each type of tile, can we tile any area with these tiles so
that like colored edges touch?
oThis problem is undecidable!
(C) 2010 Thomas J Cortina, Carnegie Mellon University
Tiling Problem
YES
Note the periodicity in the tiling.
(C) 2010 Thomas J Cortina, Carnegie Mellon University
Tiling Problem
NO
For this 3 X 3 room, if we try all 39
tiling configurations, no tiling works.
(C) 2010 Thomas J Cortina, Carnegie Mellon University
Tiling Problem
●Possible algorithm:
oIf we find a repeating pattern, report YES.
oIf we find a floor we cannot tile, report NO.
●BUT: there are some tilings which have no
repeating pattern!
(C) 2010 Thomas J Cortina, Carnegie Mellon University
Tiling Problem
●The only way to know if this set of tiles
can tile every finite-sized floor is to evaluate every
possible floor.
●BUT: there are an infinite number of finite-sized
floors!
oSo we could never answer YES in this case.
●This problem is undecidable.
(C) 2010 Thomas J Cortina, Carnegie Mellon University
Another Undecidable Problem:
The Barber Paradox
Suppose there is a town with one
male barber; and that every man in
the town keeps himself clean-shaven:
some shave themselves and some
are shaved by the barber. Only the
barber can shave another man. The
barber shaves all and only those men
who do not shave themselves.
Does the barber shave himself?(C) 2010 Thomas J Cortina, Carnegie Mellon University
Program Termination
●Can we determine if a program will terminate given a
valid input?
●Example:
1. Input x
2. While x is not equal to 1, do the following:
(a) Subtract 2 from x.
●Does this algorithm terminate when x = 15105?
●Does this algorithm terminate when x = 2008?
(C) 2010 Thomas J Cortina, Carnegie Mellon University
Program Termination
●Another Example:
1. Input x
2. While x is not equal to 1, do the following:
(a) If x is even, divide x by 2.
(b) Otherwise, Set x to 3x + 1.
●Does this algorithm terminate for x = 15?
●Does this algorithm terminate for x = 105?
●Does this algorithm terminate for any positive x?
(C) 2010 Thomas J Cortina, Carnegie Mellon University
The Halting Problem
●Can we write a general program Q that takes
as its input any program P and an input I and determines if
program P will terminate (halt) when run with input I?
oIt will answer YES if P terminates successfully on input I.
oIt will answer NO if P never terminates on input I.
●This computational problem is undecidable!
oNo such general program Q can exist!
oIt doesn’t matter how powerful the computer is.
oIt doesn’t matter how much time we devote to the computation.
oThe proof of this involves contradiction.
(C) 2010 Thomas J Cortina, Carnegie Mellon University
start
end
Does this
algorithm end?
yes
no
Contradiction
(C) 2010 Thomas J Cortina, Carnegie Mellon University
Contradiction isn't just for
computer scientists...
(C) 2010 Thomas J Cortina, Carnegie Mellon University
Ad

More Related Content

What's hot (20)

Unit 1 chapter 1 Design and Analysis of Algorithms
Unit 1   chapter 1 Design and Analysis of AlgorithmsUnit 1   chapter 1 Design and Analysis of Algorithms
Unit 1 chapter 1 Design and Analysis of Algorithms
P. Subathra Kishore, KAMARAJ College of Engineering and Technology, Madurai
 
Intro automata theory
Intro automata theory Intro automata theory
Intro automata theory
Rajendran
 
Np hard
Np hardNp hard
Np hard
jesal_joshi
 
Introduction TO Finite Automata
Introduction TO Finite AutomataIntroduction TO Finite Automata
Introduction TO Finite Automata
Ratnakar Mikkili
 
First order logic
First order logicFirst order logic
First order logic
Rushdi Shams
 
daa-unit-3-greedy method
daa-unit-3-greedy methoddaa-unit-3-greedy method
daa-unit-3-greedy method
hodcsencet
 
Asymptotic Notation
Asymptotic NotationAsymptotic Notation
Asymptotic Notation
Protap Mondal
 
Branch and bound
Branch and boundBranch and bound
Branch and bound
Dr Shashikant Athawale
 
Dynamic programming class 16
Dynamic programming class 16Dynamic programming class 16
Dynamic programming class 16
Kumar
 
Bayesian learning
Bayesian learningBayesian learning
Bayesian learning
Vignesh Saravanan
 
Notion of an algorithm
Notion of an algorithmNotion of an algorithm
Notion of an algorithm
Nisha Soms
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
Ratnakar Mikkili
 
Lecture: Automata
Lecture: AutomataLecture: Automata
Lecture: Automata
Marina Santini
 
Automata theory -RE to NFA-ε
Automata theory -RE to  NFA-εAutomata theory -RE to  NFA-ε
Automata theory -RE to NFA-ε
Akila Krishnamoorthy
 
Fundamentals of the Analysis of Algorithm Efficiency
Fundamentals of the Analysis of Algorithm EfficiencyFundamentals of the Analysis of Algorithm Efficiency
Fundamentals of the Analysis of Algorithm Efficiency
Saranya Natarajan
 
Multi Head, Multi Tape Turing Machine
Multi Head, Multi Tape Turing MachineMulti Head, Multi Tape Turing Machine
Multi Head, Multi Tape Turing Machine
Radhakrishnan Chinnusamy
 
Knowledge representation
Knowledge representationKnowledge representation
Knowledge representation
Md. Tanvir Masud
 
Game Playing in Artificial Intelligence
Game Playing in Artificial IntelligenceGame Playing in Artificial Intelligence
Game Playing in Artificial Intelligence
lordmwesh
 
Turing machine-TOC
Turing machine-TOCTuring machine-TOC
Turing machine-TOC
Maulik Togadiya
 
pushdown automata
pushdown automatapushdown automata
pushdown automata
Sujata Pardeshi
 

Viewers also liked (7)

Resources
ResourcesResources
Resources
butest
 
Introduction to AI - Third Lecture
Introduction to AI - Third LectureIntroduction to AI - Third Lecture
Introduction to AI - Third Lecture
Wouter Beek
 
Different types of functions
Different types of functionsDifferent types of functions
Different types of functions
Katrina Young
 
Knowledge representation in AI
Knowledge representation in AIKnowledge representation in AI
Knowledge representation in AI
Vishal Singh
 
Chapter 4 (final)
Chapter 4 (final)Chapter 4 (final)
Chapter 4 (final)
Nateshwar Kamlesh
 
Knowledge representation and Predicate logic
Knowledge representation and Predicate logicKnowledge representation and Predicate logic
Knowledge representation and Predicate logic
Amey Kerkar
 
Mobile-First SEO - The Marketers Edition #3XEDigital
Mobile-First SEO - The Marketers Edition #3XEDigitalMobile-First SEO - The Marketers Edition #3XEDigital
Mobile-First SEO - The Marketers Edition #3XEDigital
Aleyda Solís
 
Resources
ResourcesResources
Resources
butest
 
Introduction to AI - Third Lecture
Introduction to AI - Third LectureIntroduction to AI - Third Lecture
Introduction to AI - Third Lecture
Wouter Beek
 
Different types of functions
Different types of functionsDifferent types of functions
Different types of functions
Katrina Young
 
Knowledge representation in AI
Knowledge representation in AIKnowledge representation in AI
Knowledge representation in AI
Vishal Singh
 
Knowledge representation and Predicate logic
Knowledge representation and Predicate logicKnowledge representation and Predicate logic
Knowledge representation and Predicate logic
Amey Kerkar
 
Mobile-First SEO - The Marketers Edition #3XEDigital
Mobile-First SEO - The Marketers Edition #3XEDigitalMobile-First SEO - The Marketers Edition #3XEDigital
Mobile-First SEO - The Marketers Edition #3XEDigital
Aleyda Solís
 
Ad

Similar to Computability - Tractable, Intractable and Non-computable Function (20)

Time and space complexity
Time and space complexityTime and space complexity
Time and space complexity
Ankit Katiyar
 
Algorithms Exam Help
Algorithms Exam HelpAlgorithms Exam Help
Algorithms Exam Help
Programming Exam Help
 
Problem set3 | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
Problem set3 | Theory of Computation | Akash Anand | MTH 401A | IIT KanpurProblem set3 | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
Problem set3 | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
Vivekananda Samiti
 
Asymptotics 140510003721-phpapp02
Asymptotics 140510003721-phpapp02Asymptotics 140510003721-phpapp02
Asymptotics 140510003721-phpapp02
mansab MIRZA
 
Slide2
Slide2Slide2
Slide2
Thiti Sununta
 
On Optimization of Network-coded Scalable Multimedia Service Multicasting
On Optimization of Network-coded Scalable Multimedia Service MulticastingOn Optimization of Network-coded Scalable Multimedia Service Multicasting
On Optimization of Network-coded Scalable Multimedia Service Multicasting
Andrea Tassi
 
QMC: Transition Workshop - Probability Models for Discretization Uncertainty ...
QMC: Transition Workshop - Probability Models for Discretization Uncertainty ...QMC: Transition Workshop - Probability Models for Discretization Uncertainty ...
QMC: Transition Workshop - Probability Models for Discretization Uncertainty ...
The Statistical and Applied Mathematical Sciences Institute
 
Skiena algorithm 2007 lecture02 asymptotic notation
Skiena algorithm 2007 lecture02 asymptotic notationSkiena algorithm 2007 lecture02 asymptotic notation
Skiena algorithm 2007 lecture02 asymptotic notation
zukun
 
Algorithm Assignment Help
Algorithm Assignment HelpAlgorithm Assignment Help
Algorithm Assignment Help
Programming Homework Help
 
Big Oh.ppt
Big Oh.pptBig Oh.ppt
Big Oh.ppt
Senthil Vit
 
ON THE DUALITY FEATURE OF P-CLASS PROBLEMS AND NP COMPLETE PROBLEMS
ON THE DUALITY FEATURE OF P-CLASS PROBLEMS AND NP COMPLETE PROBLEMSON THE DUALITY FEATURE OF P-CLASS PROBLEMS AND NP COMPLETE PROBLEMS
ON THE DUALITY FEATURE OF P-CLASS PROBLEMS AND NP COMPLETE PROBLEMS
cscpconf
 
2010 3-24 cryptography stamatiou
2010 3-24 cryptography stamatiou2010 3-24 cryptography stamatiou
2010 3-24 cryptography stamatiou
vafopoulos
 
The Concurrent Constraint Programming Research Programmes -- Redux (part2)
The Concurrent Constraint Programming Research Programmes -- Redux (part2)The Concurrent Constraint Programming Research Programmes -- Redux (part2)
The Concurrent Constraint Programming Research Programmes -- Redux (part2)
Pierre Schaus
 
Traveling Salesman Problem in Distributed Environment
Traveling Salesman Problem in Distributed EnvironmentTraveling Salesman Problem in Distributed Environment
Traveling Salesman Problem in Distributed Environment
csandit
 
TRAVELING SALESMAN PROBLEM IN DISTRIBUTED ENVIRONMENT
TRAVELING SALESMAN PROBLEM IN DISTRIBUTED ENVIRONMENTTRAVELING SALESMAN PROBLEM IN DISTRIBUTED ENVIRONMENT
TRAVELING SALESMAN PROBLEM IN DISTRIBUTED ENVIRONMENT
cscpconf
 
Chapter two
Chapter twoChapter two
Chapter two
mihiretu kassaye
 
NP completeness
NP completenessNP completeness
NP completeness
Amrinder Arora
 
Unit 3
Unit 3Unit 3
Unit 3
Gunasundari Selvaraj
 
Unit 3
Unit 3Unit 3
Unit 3
GunasundariSelvaraj
 
branch bound algorithm the concept of daa.pdf
branch bound algorithm the concept of daa.pdfbranch bound algorithm the concept of daa.pdf
branch bound algorithm the concept of daa.pdf
gotafim135
 
Time and space complexity
Time and space complexityTime and space complexity
Time and space complexity
Ankit Katiyar
 
Problem set3 | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
Problem set3 | Theory of Computation | Akash Anand | MTH 401A | IIT KanpurProblem set3 | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
Problem set3 | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
Vivekananda Samiti
 
Asymptotics 140510003721-phpapp02
Asymptotics 140510003721-phpapp02Asymptotics 140510003721-phpapp02
Asymptotics 140510003721-phpapp02
mansab MIRZA
 
On Optimization of Network-coded Scalable Multimedia Service Multicasting
On Optimization of Network-coded Scalable Multimedia Service MulticastingOn Optimization of Network-coded Scalable Multimedia Service Multicasting
On Optimization of Network-coded Scalable Multimedia Service Multicasting
Andrea Tassi
 
Skiena algorithm 2007 lecture02 asymptotic notation
Skiena algorithm 2007 lecture02 asymptotic notationSkiena algorithm 2007 lecture02 asymptotic notation
Skiena algorithm 2007 lecture02 asymptotic notation
zukun
 
ON THE DUALITY FEATURE OF P-CLASS PROBLEMS AND NP COMPLETE PROBLEMS
ON THE DUALITY FEATURE OF P-CLASS PROBLEMS AND NP COMPLETE PROBLEMSON THE DUALITY FEATURE OF P-CLASS PROBLEMS AND NP COMPLETE PROBLEMS
ON THE DUALITY FEATURE OF P-CLASS PROBLEMS AND NP COMPLETE PROBLEMS
cscpconf
 
2010 3-24 cryptography stamatiou
2010 3-24 cryptography stamatiou2010 3-24 cryptography stamatiou
2010 3-24 cryptography stamatiou
vafopoulos
 
The Concurrent Constraint Programming Research Programmes -- Redux (part2)
The Concurrent Constraint Programming Research Programmes -- Redux (part2)The Concurrent Constraint Programming Research Programmes -- Redux (part2)
The Concurrent Constraint Programming Research Programmes -- Redux (part2)
Pierre Schaus
 
Traveling Salesman Problem in Distributed Environment
Traveling Salesman Problem in Distributed EnvironmentTraveling Salesman Problem in Distributed Environment
Traveling Salesman Problem in Distributed Environment
csandit
 
TRAVELING SALESMAN PROBLEM IN DISTRIBUTED ENVIRONMENT
TRAVELING SALESMAN PROBLEM IN DISTRIBUTED ENVIRONMENTTRAVELING SALESMAN PROBLEM IN DISTRIBUTED ENVIRONMENT
TRAVELING SALESMAN PROBLEM IN DISTRIBUTED ENVIRONMENT
cscpconf
 
branch bound algorithm the concept of daa.pdf
branch bound algorithm the concept of daa.pdfbranch bound algorithm the concept of daa.pdf
branch bound algorithm the concept of daa.pdf
gotafim135
 
Ad

More from Reggie Niccolo Santos (15)

Securing PHP Applications
Securing PHP ApplicationsSecuring PHP Applications
Securing PHP Applications
Reggie Niccolo Santos
 
Introduction to Web 2.0
Introduction to Web 2.0Introduction to Web 2.0
Introduction to Web 2.0
Reggie Niccolo Santos
 
UI / UX Engineering for Web Applications
UI / UX Engineering for Web ApplicationsUI / UX Engineering for Web Applications
UI / UX Engineering for Web Applications
Reggie Niccolo Santos
 
Algorithms - Aaron Bloomfield
Algorithms - Aaron BloomfieldAlgorithms - Aaron Bloomfield
Algorithms - Aaron Bloomfield
Reggie Niccolo Santos
 
Program Logic Formulation - Ohio State University
Program Logic Formulation - Ohio State UniversityProgram Logic Formulation - Ohio State University
Program Logic Formulation - Ohio State University
Reggie Niccolo Santos
 
Abstract Data Types
Abstract Data TypesAbstract Data Types
Abstract Data Types
Reggie Niccolo Santos
 
Computational Thinking and Data Representations
Computational Thinking and Data RepresentationsComputational Thinking and Data Representations
Computational Thinking and Data Representations
Reggie Niccolo Santos
 
Number Systems
Number SystemsNumber Systems
Number Systems
Reggie Niccolo Santos
 
Introduction to Game Development
Introduction to Game DevelopmentIntroduction to Game Development
Introduction to Game Development
Reggie Niccolo Santos
 
Application Testing
Application TestingApplication Testing
Application Testing
Reggie Niccolo Santos
 
Application Security
Application SecurityApplication Security
Application Security
Reggie Niccolo Santos
 
PHP MVC
PHP MVCPHP MVC
PHP MVC
Reggie Niccolo Santos
 
MySQL Transactions
MySQL TransactionsMySQL Transactions
MySQL Transactions
Reggie Niccolo Santos
 
MySQL Cursors
MySQL CursorsMySQL Cursors
MySQL Cursors
Reggie Niccolo Santos
 
MySQL Views
MySQL ViewsMySQL Views
MySQL Views
Reggie Niccolo Santos
 

Recently uploaded (20)

Top 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docxTop 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docx
Portli
 
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdfMicrosoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
TechSoup
 
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Andre Hora
 
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and CollaborateMeet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Maxim Salnikov
 
Exploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the FutureExploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the Future
ICS
 
Societal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainabilitySocietal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainability
Jordi Cabot
 
Adobe After Effects Crack FREE FRESH version 2025
Adobe After Effects Crack FREE FRESH version 2025Adobe After Effects Crack FREE FRESH version 2025
Adobe After Effects Crack FREE FRESH version 2025
kashifyounis067
 
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRYLEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
NidaFarooq10
 
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& ConsiderationsDesigning AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Dinusha Kumarasiri
 
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software DevelopmentSecure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Shubham Joshi
 
Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]
saniaaftab72555
 
Automation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath CertificateAutomation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath Certificate
VICTOR MAESTRE RAMIREZ
 
PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025
mu394968
 
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
Andre Hora
 
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage DashboardsAdobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
BradBedford3
 
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
F-Secure Freedome VPN 2025 Crack Plus Activation  New VersionF-Secure Freedome VPN 2025 Crack Plus Activation  New Version
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
saimabibi60507
 
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Eric D. Schabell
 
Kubernetes_101_Zero_to_Platform_Engineer.pptx
Kubernetes_101_Zero_to_Platform_Engineer.pptxKubernetes_101_Zero_to_Platform_Engineer.pptx
Kubernetes_101_Zero_to_Platform_Engineer.pptx
CloudScouts
 
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
AxisTechnolabs
 
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Lionel Briand
 
Top 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docxTop 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docx
Portli
 
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdfMicrosoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
TechSoup
 
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Andre Hora
 
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and CollaborateMeet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Maxim Salnikov
 
Exploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the FutureExploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the Future
ICS
 
Societal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainabilitySocietal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainability
Jordi Cabot
 
Adobe After Effects Crack FREE FRESH version 2025
Adobe After Effects Crack FREE FRESH version 2025Adobe After Effects Crack FREE FRESH version 2025
Adobe After Effects Crack FREE FRESH version 2025
kashifyounis067
 
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRYLEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
NidaFarooq10
 
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& ConsiderationsDesigning AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Dinusha Kumarasiri
 
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software DevelopmentSecure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Shubham Joshi
 
Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]
saniaaftab72555
 
Automation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath CertificateAutomation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath Certificate
VICTOR MAESTRE RAMIREZ
 
PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025
mu394968
 
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
Andre Hora
 
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage DashboardsAdobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
BradBedford3
 
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
F-Secure Freedome VPN 2025 Crack Plus Activation  New VersionF-Secure Freedome VPN 2025 Crack Plus Activation  New Version
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
saimabibi60507
 
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Eric D. Schabell
 
Kubernetes_101_Zero_to_Platform_Engineer.pptx
Kubernetes_101_Zero_to_Platform_Engineer.pptxKubernetes_101_Zero_to_Platform_Engineer.pptx
Kubernetes_101_Zero_to_Platform_Engineer.pptx
CloudScouts
 
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
AxisTechnolabs
 
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Lionel Briand
 

Computability - Tractable, Intractable and Non-computable Function

  • 1. Computability Tractable, Intractable and Non-computable functions (C) 2010 Thomas J Cortina, Carnegie Mellon University
  • 2. Efficiency ●A computer program should be totally correct, but it should also oexecute as quickly as possible (time-efficiency) ouse memory wisely (storage-efficiency) ●How do we compare programs (or algorithms in general) with respect to execution time? ovarious computers run at different speeds due to different processors ocompilers optimize code before execution othe same algorithm can be written differently depending on the programming language used (C) 2010 Thomas J Cortina, Carnegie Mellon University
  • 3. Order of Complexity ●For very large n, we express the number of operations as the order of complexity. ●Order of complexity for worst-case behavior is often expressed using Big-O notation: Number of operations Order of Complexity n O(n) n/2 + 6 O(n) 2n + 9 O(n) Usually doesn't matter what the constants are... we are only concerned about the highest power of n.(C) 2010 Thomas J Cortina, Carnegie Mellon University
  • 4. O(n) ("Linear") n (amount of data) Number of Operations n n/2 + 6 2n + 9 (C) 2010 Thomas J Cortina, Carnegie Mellon University
  • 5. Order of Complexity Number of operations Order of Complexity n2 O(n2) 2n2 + 7 O(n2) n2/2 + 5n + 2 O(n2) Usually doesn't matter what the constants are... we are only concerned about the highest power of n. (C) 2010 Thomas J Cortina, Carnegie Mellon University
  • 6. O(n2) ("Quadratic") n (amount of data) Number of Operations n2/2 + 5n + 22n2 + 7 n2 (C) 2010 Thomas J Cortina, Carnegie Mellon University
  • 7. Order of Complexity Number of operations Order of Complexity log2n O(log n) log10n O(log n) 2(log2n) + 5 O(log n) The logarithm base is not written in big O notation since all that matters is that the function is logarithmic. (C) 2010 Thomas J Cortina, Carnegie Mellon University
  • 8. O(log n) ("Logarithmic") n (amount of data) Number of Operations log2 n log10 n 2(log2 n) + 5 (C) 2010 Thomas J Cortina, Carnegie Mellon University
  • 9. Comparing Big O Functions n (amount of data) Number of Operations O(2n) O(1) O(n log n) O(log n) O(n2) O(n) (C) 2010 Thomas J Cortina, Carnegie Mellon University
  • 10. Searching & Sorting WORST CASE Order Of Complexity on N data elements ●Linear Search O(N) ●Binary Search O(log N) ●Selection Sort O(N2) ●Bubble Sort O(N2) ●Merge Sort O(N log N) ●Quick Sort O(N2) ●Sort + Binary Search O(N log N) + O(log N) = O(N log N) (C) 2010 Thomas J Cortina, Carnegie Mellon University
  • 11. Comparing Algorithms ●Assume an algorithm processes n data values. If each operation takes 1 s to execute, how many s will it take to run the algorithm on 100 data values if the algorithm has the following number of computations? Number of Computations Execution Time n 100 s n • log2 n 665 s n2 10,000 s n3 1,000,000 s = 1 sec 2n > 1030 s n! > 10160 s (C) 2010 Thomas J Cortina, Carnegie Mellon University
  • 12. Decision Problems ●A specific set of computations are classified as decision problems. ●An algorithm describes a decision problem if its output is simply YES or NO, depending on whether a certain property holds for its input. ●Example: Given a set of n shapes, can these shapes be arranged into a rectangle? (C) 2010 Thomas J Cortina, Carnegie Mellon University
  • 13. Monkey Puzzle Problem ●Given: oA set of n square cards whose sides are imprinted with the upper and lower halves of colored monkeys. on is a square number, such that n = m2. oCards cannot be rotated. ●Problem: oDetermine if an arrangement of the n cards in an m X m grid exists such that each adjacent pair of cards display the upper and lower half of a monkey of the same color. Source: www.dwheeler.com (2002)(C) 2010 Thomas J Cortina, Carnegie Mellon University
  • 14. Example Images from: Simonas Šaltenis, Aalborg University, [email protected] 1 2 3 4 5 6 7 8 9 (C) 2010 Thomas J Cortina, Carnegie Mellon University
  • 15. Analysis Simple algorithm: ●Pick one card for each cell of m X m grid. ●Verify if each pair of touching edges make a full monkey of the same color. ●If not, try another arrangement until a solution is found or all possible arrangements are checked. ●Answer "YES" if a solution is found. Otherwise, answer "NO" if all arrangements are analyzed and no solution is found. (C) 2010 Thomas J Cortina, Carnegie Mellon University
  • 16. Analysis If there are n = 9 cards (m = 3): To fill the first cell, we have 9 card choices. To fill the second cell, we have 8 card choices left. To fill the third cell, we have 7 card choices remaining. etc.The total number of unique arrangements for n = 9 cards is: 9 * 8 * 7 * 6 * 5 * 4 * 3 * 2 * 1 = 362,880 (C) 2010 Thomas J Cortina, Carnegie Mellon University
  • 17. Analysis For n cards, the number of arrangements to examine is n! (n factorial) If we can analyze one arrangement in a microsecond: n Time to analyze all arrangements 9 362,880 s = 0.36288 s 16 20,922,789,888,000 s ≈ 242 days 25 15,511,210,043,330,985,984,000,000 s ≈ 491,520,585,955 years(C) 2010 Thomas J Cortina, Carnegie Mellon University
  • 18. Map Coloring ●Given a map of n territories, can the map be colored using k colors such that no two adjacent territories are colored with the same color? ●k=4: Answer is always yes. ●k=2: Only if the map contains no point that is the junction of an odd number of territories. (C) 2010 Thomas J Cortina, Carnegie Mellon University
  • 19. Map Coloring (C) 2010 Thomas J Cortina, Carnegie Mellon University
  • 20. Map Coloring ●Given a map of 48 territories, can the map be colored using 3 colors such that no two adjacent territories are colored with the same color? oPick a color for California (3 choices) oPick a color for Nevada (3 choices) o... ●There are 348 = 79,766,443,076,872,509,863,361 possible colorings. ●No one has come up with a better algorithmic solution that works in general for any map, so far.(C) 2010 Thomas J Cortina, Carnegie Mellon University
  • 21. Classifications ●Algorithms that are O(nk) for some fixed k are polynomial-time algorithms. oO(1), O(log n), O(n), O(n log n), O(n2) oreasonable, tractable ●All other algorithms are super-polynomial- time algorithms. oO(2n), O(n!), O(nn) ounreasonable, intractable (C) 2010 Thomas J Cortina, Carnegie Mellon University
  • 22. Traveling Salesperson ●Given: a weighted graph of nodes representing cities and edges representing flight paths (weights represent cost) ●Is there a route that takes the salesperson through every city and back to the starting city with cost no more than k? oThe salesperson can visit a city only once (except for the start and end of the trip). (C) 2010 Thomas J Cortina, Carnegie Mellon University
  • 23. Traveling Salesperson A B D C G E F 12 6 4 5 9 8 10 7 11 3 7 7 Is there a route with cost at most 52? YES (Route above costs 50.) Is there a route with cost at most 48? YES? NO? (C) 2010 Thomas J Cortina, Carnegie Mellon University
  • 24. Traveling Salesperson ●If there are n cities, what is the maximum number of routes that we might need to compute? ●Worst-case: There is a flight available between every pair of cities. ●Compute cost of every possible route. oPick a starting city oPick the next city (n-1 choices remaining) oPick the next city (n-2 choices remaining) o... ●Maximum number of routes: (n-1)! = O(n!) how to build a route (C) 2010 Thomas J Cortina, Carnegie Mellon University
  • 25. P and NP ●The class P consists of all those decision problems that can be solved on a deterministic sequential machine (e.g. a computer) in an amount of time that is polynomial with respect to the size of the input ●The class NP consists of all those decision problems whose positive solutions can be verified in polynomial time given the right information. from Wikipedia (C) 2010 Thomas J Cortina, Carnegie Mellon University
  • 26. NP Complete ●The class NPC consists of all those problems in NP that are least likely to be in P. oEach of these problems is called NP Complete. oMonkey puzzle, Traveling salesperson, Hamiltonian path, map coloring, satisfiability are all in NPC. ●Every problem in NPC can be transformed to another problem in NPC. oIf there were some way to solve one of these problems in polynomial time, we should be able to solve all of these problems in polynomial time. (C) 2010 Thomas J Cortina, Carnegie Mellon University
  • 27. Complexity Classes NP Problems P Problems NP Complete Problems But does P = NP? If P ≠ NP, then all decision problems can be broken down into this classification scheme. If P = NP, then all three classes are one and the same. The Clay Mathematics Institute is offering a $1M prize for the first person to prove P = NP or P ≠ NP. (http://www.claymath.org/millennium/P_vs_NP/) We know that P < NP, since any problem that can be solved in polynomial time can certainly have a solution verified in polynomial time. (C) 2010 Thomas J Cortina, Carnegie Mellon University
  • 28. (C) 2010 Thomas J Cortina, Carnegie Mellon University
  • 29. It gets worse... ●Tractable Problems oProblems that have reasonable, polynomial-time solutions ●Intractable Problems oProblems that have no reasonable, polynomial-time solutions ●Noncomputable Problems oProblems that have no algorithms at all to solve them (C) 2010 Thomas J Cortina, Carnegie Mellon University
  • 30. Noncomputability and Undecidability ●An algorithmic problem that has no algorithm is called noncomputable. ●If the noncomputable algorithm requires a yes/no answer, the problem is called undecidable. ●Example: oGiven any set of any number of different tile designs (examples shown above), with an infinite number of each type of tile, can we tile any area with these tiles so that like colored edges touch? oThis problem is undecidable! (C) 2010 Thomas J Cortina, Carnegie Mellon University
  • 31. Tiling Problem YES Note the periodicity in the tiling. (C) 2010 Thomas J Cortina, Carnegie Mellon University
  • 32. Tiling Problem NO For this 3 X 3 room, if we try all 39 tiling configurations, no tiling works. (C) 2010 Thomas J Cortina, Carnegie Mellon University
  • 33. Tiling Problem ●Possible algorithm: oIf we find a repeating pattern, report YES. oIf we find a floor we cannot tile, report NO. ●BUT: there are some tilings which have no repeating pattern! (C) 2010 Thomas J Cortina, Carnegie Mellon University
  • 34. Tiling Problem ●The only way to know if this set of tiles can tile every finite-sized floor is to evaluate every possible floor. ●BUT: there are an infinite number of finite-sized floors! oSo we could never answer YES in this case. ●This problem is undecidable. (C) 2010 Thomas J Cortina, Carnegie Mellon University
  • 35. Another Undecidable Problem: The Barber Paradox Suppose there is a town with one male barber; and that every man in the town keeps himself clean-shaven: some shave themselves and some are shaved by the barber. Only the barber can shave another man. The barber shaves all and only those men who do not shave themselves. Does the barber shave himself?(C) 2010 Thomas J Cortina, Carnegie Mellon University
  • 36. Program Termination ●Can we determine if a program will terminate given a valid input? ●Example: 1. Input x 2. While x is not equal to 1, do the following: (a) Subtract 2 from x. ●Does this algorithm terminate when x = 15105? ●Does this algorithm terminate when x = 2008? (C) 2010 Thomas J Cortina, Carnegie Mellon University
  • 37. Program Termination ●Another Example: 1. Input x 2. While x is not equal to 1, do the following: (a) If x is even, divide x by 2. (b) Otherwise, Set x to 3x + 1. ●Does this algorithm terminate for x = 15? ●Does this algorithm terminate for x = 105? ●Does this algorithm terminate for any positive x? (C) 2010 Thomas J Cortina, Carnegie Mellon University
  • 38. The Halting Problem ●Can we write a general program Q that takes as its input any program P and an input I and determines if program P will terminate (halt) when run with input I? oIt will answer YES if P terminates successfully on input I. oIt will answer NO if P never terminates on input I. ●This computational problem is undecidable! oNo such general program Q can exist! oIt doesn’t matter how powerful the computer is. oIt doesn’t matter how much time we devote to the computation. oThe proof of this involves contradiction. (C) 2010 Thomas J Cortina, Carnegie Mellon University
  • 39. start end Does this algorithm end? yes no Contradiction (C) 2010 Thomas J Cortina, Carnegie Mellon University
  • 40. Contradiction isn't just for computer scientists... (C) 2010 Thomas J Cortina, Carnegie Mellon University