1 joe meehean. log: binary search in sorted array linear: traverse a tree log-linear: insert into...
TRANSCRIPT
![Page 1: 1 Joe Meehean. Log: binary search in sorted array Linear: traverse a tree Log-Linear: insert into a heap Quadratic (N 2 ): your sort from P1](https://reader035.vdocument.in/reader035/viewer/2022072016/56649ed55503460f94be5abb/html5/thumbnails/1.jpg)
1
NP Complete
Joe Meehean
![Page 2: 1 Joe Meehean. Log: binary search in sorted array Linear: traverse a tree Log-Linear: insert into a heap Quadratic (N 2 ): your sort from P1](https://reader035.vdocument.in/reader035/viewer/2022072016/56649ed55503460f94be5abb/html5/thumbnails/2.jpg)
2
Complexities we’ve seen
Log: binary search in sorted array
Linear: traverse a tree
Log-Linear: insert into a heap
Quadratic (N2): your sort from P1 Exponential (NN): brute force
map coloring
![Page 3: 1 Joe Meehean. Log: binary search in sorted array Linear: traverse a tree Log-Linear: insert into a heap Quadratic (N 2 ): your sort from P1](https://reader035.vdocument.in/reader035/viewer/2022072016/56649ed55503460f94be5abb/html5/thumbnails/3.jpg)
3
Polynomial Time Upper bound is Nk for N inputs
• e.g., O(logN), O(N), O(NlogN), O(N2), … Problems in class P
• have known polynomial time solutions
![Page 4: 1 Joe Meehean. Log: binary search in sorted array Linear: traverse a tree Log-Linear: insert into a heap Quadratic (N 2 ): your sort from P1](https://reader035.vdocument.in/reader035/viewer/2022072016/56649ed55503460f94be5abb/html5/thumbnails/4.jpg)
4
Non-deterministic vs. Deterministic
Slipping into computational theory Deterministic programs
• like the ones we write in C++• must search or construct the correct answer• if there are many possible solutions must
check them all• OR carefully construct the answer piece-
wise
![Page 5: 1 Joe Meehean. Log: binary search in sorted array Linear: traverse a tree Log-Linear: insert into a heap Quadratic (N 2 ): your sort from P1](https://reader035.vdocument.in/reader035/viewer/2022072016/56649ed55503460f94be5abb/html5/thumbnails/5.jpg)
5
Non-deterministic vs. Deterministic
Non-deterministic programs• currently exist only in theory• program guided by all knowing oracle• oracle can create a possible solution to the
problem for free• solution is often the correct one
if a solution exists
![Page 6: 1 Joe Meehean. Log: binary search in sorted array Linear: traverse a tree Log-Linear: insert into a heap Quadratic (N 2 ): your sort from P1](https://reader035.vdocument.in/reader035/viewer/2022072016/56649ed55503460f94be5abb/html5/thumbnails/6.jpg)
6
Non-deterministic Polynomial Time
Think about reducing problem to yes/no
Given a potential solution to problem• is it possible to determine whether it is
correct in polynomial time Problems like this are in the NP class
• if in NP, but not P then there is no known polynomial time solution for these problems
• but we can check answers in polynomial time
![Page 7: 1 Joe Meehean. Log: binary search in sorted array Linear: traverse a tree Log-Linear: insert into a heap Quadratic (N 2 ): your sort from P1](https://reader035.vdocument.in/reader035/viewer/2022072016/56649ed55503460f94be5abb/html5/thumbnails/7.jpg)
7
Non-deterministic Polynomial Time
e.g., graph coloring• given a potential coloring of vertices• for each vertex compare its colors to
its neighbors • O(E + V) = polynomial time• only need one correct k coloring to prove
graph can be colored with k colors
![Page 8: 1 Joe Meehean. Log: binary search in sorted array Linear: traverse a tree Log-Linear: insert into a heap Quadratic (N 2 ): your sort from P1](https://reader035.vdocument.in/reader035/viewer/2022072016/56649ed55503460f94be5abb/html5/thumbnails/8.jpg)
8
Problem Complexity
NP
P
![Page 9: 1 Joe Meehean. Log: binary search in sorted array Linear: traverse a tree Log-Linear: insert into a heap Quadratic (N 2 ): your sort from P1](https://reader035.vdocument.in/reader035/viewer/2022072016/56649ed55503460f94be5abb/html5/thumbnails/9.jpg)
9
NP Complete Problems Hardest problems in NP Any problem in NP can be polynomially
reduced to all NP complete problems• NP problem A can be translated into NP
complete problem B in polynomial time• e.g. calculator
numbers entered in decimal converted to binary and solved in binary converted back to decimal
Min color graph coloring is NP complete
![Page 10: 1 Joe Meehean. Log: binary search in sorted array Linear: traverse a tree Log-Linear: insert into a heap Quadratic (N 2 ): your sort from P1](https://reader035.vdocument.in/reader035/viewer/2022072016/56649ed55503460f94be5abb/html5/thumbnails/10.jpg)
10
Problem Complexity
NP
P NP Complete
maybe
![Page 11: 1 Joe Meehean. Log: binary search in sorted array Linear: traverse a tree Log-Linear: insert into a heap Quadratic (N 2 ): your sort from P1](https://reader035.vdocument.in/reader035/viewer/2022072016/56649ed55503460f94be5abb/html5/thumbnails/11.jpg)
11
NP Complete If we can solve an NP complete
problem A in polynomial time• we can use it as a method (sub routine) to
solve other NP problem B• just translate the B into A in polynomial
time• solve A• translate solution back into B• polynomial time + polynomial time =
polynomial time
![Page 12: 1 Joe Meehean. Log: binary search in sorted array Linear: traverse a tree Log-Linear: insert into a heap Quadratic (N 2 ): your sort from P1](https://reader035.vdocument.in/reader035/viewer/2022072016/56649ed55503460f94be5abb/html5/thumbnails/12.jpg)
12
NP Complete If we can solve an NP complete
problem A in polynomial time• we can solve ALL NP problems in
polynomial time• P = NP
![Page 13: 1 Joe Meehean. Log: binary search in sorted array Linear: traverse a tree Log-Linear: insert into a heap Quadratic (N 2 ): your sort from P1](https://reader035.vdocument.in/reader035/viewer/2022072016/56649ed55503460f94be5abb/html5/thumbnails/13.jpg)
13
Problem Complexity
NP
P
NP Complete
![Page 14: 1 Joe Meehean. Log: binary search in sorted array Linear: traverse a tree Log-Linear: insert into a heap Quadratic (N 2 ): your sort from P1](https://reader035.vdocument.in/reader035/viewer/2022072016/56649ed55503460f94be5abb/html5/thumbnails/14.jpg)
14
NP Complete P = NP? No one has solved an NP complete
problem in polynomial time …Yet
![Page 15: 1 Joe Meehean. Log: binary search in sorted array Linear: traverse a tree Log-Linear: insert into a heap Quadratic (N 2 ): your sort from P1](https://reader035.vdocument.in/reader035/viewer/2022072016/56649ed55503460f94be5abb/html5/thumbnails/15.jpg)
15
Undecidable problems Problems that are impossible to
solve using a Turing machine-based computer• impossible to solve with modern
computers E.g., halting problem
• does a program have an infinite loop?• proof is simple to explain• proof is hard to understand
involves recursion and impossible outcomes
![Page 16: 1 Joe Meehean. Log: binary search in sorted array Linear: traverse a tree Log-Linear: insert into a heap Quadratic (N 2 ): your sort from P1](https://reader035.vdocument.in/reader035/viewer/2022072016/56649ed55503460f94be5abb/html5/thumbnails/16.jpg)
16
Questions?