CS 146: Data Structures and Algorithms August 4 Class Meeting Department of Computer Science San Jose State University Summer 2015 Instructor: Ron Mak.

Slides:



Advertisements
Similar presentations
Analysis of Algorithms
Advertisements

Complexity Classes: P and NP
NP-Hard Nattee Niparnan.
Chapter 11 Limitations of Algorithm Power Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
What is Intractable? Some problems seem too hard to solve efficiently. Question 1: Does an efficient algorithm exist?  An O(a ) algorithm, where a > 1,
1 NP-completeness Lecture 2: Jan P The class of problems that can be solved in polynomial time. e.g. gcd, shortest path, prime, etc. There are many.
Lecture 21 NP-complete problems
The Theory of NP-Completeness
1 NP-Complete Problems. 2 We discuss some hard problems:  how hard? (computational complexity)  what makes them hard?  any solutions? Definitions 
CSE373: Data Structures & Algorithms Lecture 24: The P vs. NP question, NP-Completeness Nicki Dell Spring 2014 CSE 373 Algorithms and Data Structures 1.
Algorithm Strategies Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
CSE332: Data Abstractions Lecture 27: A Few Words on NP Dan Grossman Spring 2010.
NP-Complete Problems Reading Material: Chapter 10 Sections 1, 2, 3, and 4 only.
The Theory of NP-Completeness
NP-Complete Problems Problems in Computer Science are classified into
CSE 326: Data Structures NP Completeness Ben Lerner Summer 2007.
Analysis of Algorithms CS 477/677
CSE 421 Algorithms Richard Anderson Lecture 27 NP Completeness.
Chapter 11: Limitations of Algorithmic Power
Chapter 11 Limitations of Algorithm Power Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
Chapter 11 Limitations of Algorithm Power Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
CS 146: Data Structures and Algorithms July 14 Class Meeting Department of Computer Science San Jose State University Summer 2015 Instructor: Ron Mak
Instructor: Dr. Sahar Shabanah Fall Lectures ST, 9:30 pm-11:00 pm Text book: M. T. Goodrich and R. Tamassia, “Data Structures and Algorithms in.
Programming & Data Structures
1 CSC 421: Algorithm Design & Analysis Spring 2013 Complexity & Computability  lower bounds on problems brute force, decision trees, adversary arguments,
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:
CSCE350 Algorithms and Data Structure
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.
Nattee Niparnan. Easy & Hard Problem What is “difficulty” of problem? Difficult for computer scientist to derive algorithm for the problem? Difficult.
Tonga Institute of Higher Education Design and Analysis of Algorithms IT 254 Lecture 8: Complexity Theory.
Fundamentals of Algorithms MCS - 2 Lecture # 7
Cs3102: Theory of Computation Class 24: NP-Completeness Spring 2010 University of Virginia David Evans.
CSC 413/513: Intro to Algorithms NP Completeness.
Week 10Complexity of Algorithms1 Hard Computational Problems Some computational problems are hard Despite a numerous attempts we do not know any efficient.
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.
CSE373: Data Structures & Algorithms Lecture 22: The P vs. NP question, NP-Completeness Lauren Milne Summer 2015.
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.
CSE 421 Algorithms Richard Anderson Lecture 27 NP-Completeness and course wrap up.
NP-Complete problems.
CS 146: Data Structures and Algorithms July 14 Class Meeting Department of Computer Science San Jose State University Summer 2015 Instructor: Ron Mak
Design and Analysis of Algorithms - Chapter 101 Our old list of problems b Sorting b Searching b Shortest paths in a graph b Minimum spanning tree b Primality.
NP-Complete Problems Algorithm : Design & Analysis [23]
CS 3343: Analysis of Algorithms Lecture 25: P and NP Some slides courtesy of Carola Wenk.
Types of Algorithms. 2 Algorithm classification Algorithms that use a similar problem-solving approach can be grouped together We’ll talk about a classification.
SPANNING TREES Lecture 20 CS2110 – Fall Spanning Trees  Definitions  Minimum spanning trees  3 greedy algorithms (incl. Kruskal’s & Prim’s)
LIMITATIONS OF ALGORITHM POWER
CS6045: Advanced Algorithms NP Completeness. NP-Completeness Some problems are intractable: as they grow large, we are unable to solve them in reasonable.
CSE 340: Review (at last!) Measuring The Complexity Complexity is a function of the size of the input O() Ω() Θ() Complexity Analysis “same order” Order.
NPC.
Young CS 331 D&A of Algo. NP-Completeness1 NP-Completeness Reference: Computers and Intractability: A Guide to the Theory of NP-Completeness by Garey and.
1 Ch 10 - NP-completeness Tractable and intractable problems Decision/Optimization problems Deterministic/NonDeterministic algorithms Classes P and NP.
CS 146: Data Structures and Algorithms July 28 Class Meeting Department of Computer Science San Jose State University Summer 2015 Instructor: Ron Mak
The Theory of NP-Completeness 1. Nondeterministic algorithms A nondeterminstic algorithm consists of phase 1: guessing phase 2: checking If the checking.
2016/3/13Page 1 Semester Review COMP3040 Dept. Computer Science and Technology United International College.
1 P and NP. 2 Introduction The Traveling Salesperson problem and thousands of other problems are equally hard in the sense that if we had an efficient.
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.
CSE 332: NP Completeness, Part II Richard Anderson Spring 2016.
ICS 353: Design and Analysis of Algorithms NP-Complete Problems King Fahd University of Petroleum & Minerals Information & Computer Science Department.
Lecture 22 Complexity and Reductions
Analysis and design of algorithm
ICS 353: Design and Analysis of Algorithms
Chapter 11 Limitations of Algorithm Power
NP-Completeness Reference: Computers and Intractability: A Guide to the Theory of NP-Completeness by Garey and Johnson, W.H. Freeman and Company, 1979.
Algorithms CSCI 235, Spring 2019 Lecture 36 P vs
Presentation transcript:

CS 146: Data Structures and Algorithms August 4 Class Meeting Department of Computer Science San Jose State University Summer 2015 Instructor: Ron Mak

Computer Science Dept. Summer 2015: August 4 CS 146: Data Structures and Algorithms © R. Mak Computing KMP next[] For each value of i, attempt to match the pattern’s prefix and suffix, and set next[i] to the length of the match. ijnext[i] Patternababaca next[] Patternababaca next[] Patternababaca next[] Patternababaca next[] Patternababaca next[] Patternababaca next[]

Computer Science Dept. Summer 2015: August 4 CS 146: Data Structures and Algorithms © R. Mak 3 KMP Pattern Matching Textbacbabababacaca Patternababaca Textbacbabababacaca Patternababaca Textbacbabababacaca Patternababaca Textbacbabababacaca Patternababaca i = 0, j=0, no match Shift pattern 1 right i = 1, j=0, match i = 2, j=1, no match Reset j = next[0] = 0 i = 2, j=0, no match Shift pattern 1 right next = [ ]

Computer Science Dept. Summer 2015: August 4 CS 146: Data Structures and Algorithms © R. Mak We already know that aba has matched, so we jump the pattern forward to align it with the previous occurrence of aba. 4 KMP Pattern Matching, cont’d Textbacbabababacaca Patternababaca Textbacbabababacaca Patternababaca i = 9, j=5, no match Reset j = next[4] = 3 i = 9..12, j=3..6, matches Pattern found in text. Textbacbabababacaca Patternababaca i = 4..8, j=0..4, matches next = [ ] Textbacbabababacaca Patternababaca i = 3, j=0, no match Shift pattern 1 right

Computer Science Dept. Summer 2015: August 4 CS 146: Data Structures and Algorithms © R. Mak 5 Algorithm Running Times  Many of the algorithms we’ve seen have polynomial running times. Example: Insertion sort: Θ(N 2 )  Some have linear or near linear running times. Example: Building a heap: O(N) Example: Merge sort: O(N log N)  We’ve also seen exponential running times. Example: Solving Towers of Hanoi: Θ(2 N )

Computer Science Dept. Summer 2015: August 4 CS 146: Data Structures and Algorithms © R. Mak 6 Algorithm Running Times, cont’d  Do we always have efficient (non-exponential growth) solutions to problems?  For many problems, the answer is No.  Worse: For a large class of problems, we can’t even tell whether or not an efficient solution might exist. Programmers: You can’t find an efficient algorithm. Theoreticians: Why are these problems so hard?

Computer Science Dept. Summer 2015: August 4 CS 146: Data Structures and Algorithms © R. Mak 7 Algorithm Running Times, cont’d  We can classify problems as being “easy” or “hard”.  A great deal of computer science research has gone into this.  We now have mechanisms to classify a new problem as being “as hard as” another problem already known to be hard.

Computer Science Dept. Summer 2015: August 4 CS 146: Data Structures and Algorithms © R. Mak 8 Easy vs. Hard Problems  There can be a fine line between easy and hard.  Easy: Find the shortest path from vertex A to vertex B in a weighted graph. Do a breadth-first search in linear time.  Hard: Find the longest path (without cycles) from vertex A to vertex B in a weighted graph. All known algorithms take exponential time.

Computer Science Dept. Summer 2015: August 4 CS 146: Data Structures and Algorithms © R. Mak 9 Easy vs. Hard Problems, cont’d  Recast the problem as a Yes-No problem.  Easy: Is there a path from vertex A to vertex B with weight ≤ M ?  Hard: Is there a path from vertex A to vertex B with weight ≥ M ?

Computer Science Dept. Summer 2015: August 4 CS 146: Data Structures and Algorithms © R. Mak 10 Reductions  Reduction allows us to solve one problem in terms of another problem.  When we wish to understand the difficulty of a problem, reduction allows us to make relative statements about the upper and lower bounds on the cost of a problem. Cost of a problem, not of a particular algorithm.

Computer Science Dept. Summer 2015: August 4 CS 146: Data Structures and Algorithms © R. Mak 11 Reduction Example  Sorting: Input: A sequence of integers x 0, x 1, x 2,..., x N-1 Output: A permutation y 0, y 1, y 2,..., y N-1 of the sequence such that y i ≤ y j whenever i < j.

Computer Science Dept. Summer 2015: August 4 CS 146: Data Structures and Algorithms © R. Mak 12 Reduction Example, cont’d  Pairing: Input: Two sequences of integers X = x 0, x 1, x 2,..., x N-1 and Y = y 0, y 1, y 2,..., y N-1 Output: A pairing of the elements in the two sequences such the smallest value in X is paired with the smallest value in Y, the next smallest value in X is paired with the next smallest value in Y, etc. X : Y :

Computer Science Dept. Summer 2015: August 4 CS 146: Data Structures and Algorithms © R. Mak 13 Reduction Example, cont’d  The reduction: pairing  sorting 1. Convert the one instance of the pairing problem into two instances of a sorting problem. 2. Sort the X and Y sequences. 3. Convert the sorting output into the pairing output.  Cost analysis An upper bound for sorting for sorting is O(N log N ). Therefore, an upper bound for pairing is also O(N log N ).

Computer Science Dept. Summer 2015: August 4 CS 146: Data Structures and Algorithms © R. Mak 14 Polynomial Running Times  “Easy” problems have polynomial running times.  “Hard” problems have exponential running times.  Polynomials have useful properties.

Computer Science Dept. Summer 2015: August 4 CS 146: Data Structures and Algorithms © R. Mak 15 Polynomial Running Times, cont’d  Polynomials are closed under addition and composition.  Running two algorithms in sequence, each with polynomial running time, together has polynomial running time.  Having one algorithm with polynomial running time call another algorithm several times, the latter also with polynomial running time, together has polynomial running time.

Computer Science Dept. Summer 2015: August 4 CS 146: Data Structures and Algorithms © R. Mak 16 Polynomial Running Times, cont’d  Computers are polynomially related.  Any algorithm that runs in polynomial time today, when transferred to any other computer today or in the future, will still run in polynomial time.

Computer Science Dept. Summer 2015: August 4 CS 146: Data Structures and Algorithms © R. Mak 17 Determinism vs. Nondeterminism  On a deterministic machine: The next step (instruction) to execute is uniquely determined by the current instruction.  On a (theoretical) nondeterministic machine: There is a choice of next steps. The machine can evaluate all its next steps in parallel. It is free to choose any step it wishes. If one of the steps leads to a solution to a problem, it will always choose the correct one.

Computer Science Dept. Summer 2015: August 4 CS 146: Data Structures and Algorithms © R. Mak 18 Determinism vs. Nondeterminism, cont’d  A nondeterministic machine has the power of extremely good, optimal guessing. Guessing = checking all possible problem solutions in parallel to determine which one is correct.

Computer Science Dept. Summer 2015: August 4 CS 146: Data Structures and Algorithms © R. Mak 19 Nondeterministic Machine  Suppose that: We have a problem whose solution a nondeterministic computer can guess in polynomial time. We can check in polynomial time the correctness of this solution. Then we can claim that our nondeterministic computer can solve the problem in polynomial time.  Nondeterministic algorithm: An algorithm that works in this manner (guess and test in polynomial time). ..

Computer Science Dept. Summer 2015: August 4 CS 146: Data Structures and Algorithms © R. Mak 20 NP  Any problem that runs on a nondeterministic machine in polynomial time is in class NP.  NP = nondeterministic polynomial-time  The class of all problems that can be solved in polynomial time on a nondeterministic machine.

Computer Science Dept. Summer 2015: August 4 CS 146: Data Structures and Algorithms © R. Mak 21 NP, cont’d  Recall our example of a Yes-No problem: Easy: Is there a path from vertex A to vertex B with weight ≤ M ? Hard: Is there a path from vertex A to vertex B with weight ≥ M ?  A problem is in NP if we can prove that any “yes” answer is correct in polynomial time. We can ignore “no” answers because the nondeterministic machine always makes the right choice.

Computer Science Dept. Summer 2015: August 4 CS 146: Data Structures and Algorithms © R. Mak 22 The Traveling Salesman Problem  In plain English:  Find the shortest route for a salesman to visit every state capitol exactly once.

Computer Science Dept. Summer 2015: August 4 CS 146: Data Structures and Algorithms © R. Mak 23 The Traveling Salesman Problem, cont’d  As a graph problem: Input: A complete directed graph G with positive distances assigned to each edge of the graph. Output: The shortest simple cycle that includes every vertex.  As Yes-No problem: Input: A complete directed graph G with positive distances assigned to each edge of the graph, and an integer k. Output: YES if there is a simple cycle with total distance ≤ k containing every vertex; NO otherwise.

Computer Science Dept. Summer 2015: August 4 CS 146: Data Structures and Algorithms © R. Mak 24 The Traveling Salesman Problem, cont’d  With a nondeterministic computer, we can solve the Yes-No problem in polynomial time.  Check all possible subsets of graph edges in parallel.  Verify the edges form a cycle and visits each vertex exactly once, add up their distances.  If any subset of edges is an appropriate cycle of total length ≤ k, the answer is YES; otherwise, the answer is NO.

Computer Science Dept. Summer 2015: August 4 CS 146: Data Structures and Algorithms © R. Mak 25 The Traveling Salesman Problem, cont’d  This algorithm cannot be converted to polynomial time on a regular (deterministic) computer.  There are 2 |E| subsets to check.  Nobody knows of any polynomial time algorithm to solve the traveling salesman problem on a regular computer.

Computer Science Dept. Summer 2015: August 4 CS 146: Data Structures and Algorithms © R. Mak 26 NP-Complete  This is the class of the hardest problems.  We know there are efficient nondeterministic algorithms.  We cannot prove that any of these problems do not have efficient deterministic algorithms.  An NP-complete problem has the property that any problem in NP can be reduced to it.

Computer Science Dept. Summer 2015: August 4 CS 146: Data Structures and Algorithms © R. Mak 27 NP-Complete, cont’d  If you can find a solution to an NP-complete problem that runs in polynomial time on a regular computer …  Then by a series of reductions, every other problem in NP can also be solved in polynomial time on a regular computer.  If you can find an efficient algorithm that solves any NP-complete problem, you will have an efficient algorithm to solve all of them.

Computer Science Dept. Summer 2015: August 4 CS 146: Data Structures and Algorithms © R. Mak 28 NP-Complete, cont’d  To prove a new problem is NP-complete:  Show that it’s in NP.  Show that you can reduce an existing NP-complete problem to the new problem.

Computer Science Dept. Summer 2015: August 4 CS 146: Data Structures and Algorithms © R. Mak 29 NP-Complete, cont’d  The very first NP-complete problem is satisfiability.  Input: A boolean expression E over the variables x 1, x 2,... in conjunctive normal form. Conjunctive normal form: A boolean expression that is a series of clauses that are AND’ed together.  Output: YES if there is an assignment to the variables that makes E true; otherwise NO.

Computer Science Dept. Summer 2015: August 4 CS 146: Data Structures and Algorithms © R. Mak 30 NP-Complete Problems  Satisfiablility  Traveling salesman  Partition Divide a given set of integers into two sets with equal sums.  Integer linear programming Find an integer solution to a given linear programming problem.

Computer Science Dept. Summer 2015: August 4 CS 146: Data Structures and Algorithms © R. Mak 31 NP-Complete Problems, cont’d  Multiprocessor scheduling Assign tasks of varying lengths to identical processors in order to meet a deadline.  Clique Find a subset of Facebook subscribers all of whom are friends with each other.

Computer Science Dept. Summer 2015: August 4 CS 146: Data Structures and Algorithms © R. Mak 32 P  Class P is the set of all problems that can be solved by deterministic algorithms in polynomial time. Example: Insertion sort: Θ(N 2 ) Exponential time problems Towers of Hanoi NP problems NP-complete problems Traveling salesman P problems Sorting

Computer Science Dept. Summer 2015: August 4 CS 146: Data Structures and Algorithms © R. Mak 33 Is P = NP? cont’d  As powerful as nondeterminism is, no one has yet been able to prove that it helps with any particular problem.  In other words, no one has been able to find a single problem that can be proven to be in NP but not in P (or even prove that such a problem exists).  We do not know whether or not P = NP. Exponential time problems NP problems NP-complete problems P problems

Computer Science Dept. Summer 2015: August 4 CS 146: Data Structures and Algorithms © R. Mak 34 Is P = NP? cont’d  If you can prove that a problem is not in P, then you can abandon a search for an efficient solution.  In the absence of such a proof, there is the possibility that an efficient algorithm has gone undiscovered.  There could be an efficient algorithm for every problem in NP, which implies that many efficient algorithms are still undiscovered.

Computer Science Dept. Summer 2015: August 4 CS 146: Data Structures and Algorithms © R. Mak 35 Is P = NP? cont’d  Virtually no computer scientists believe that P = NP.  But it’s still an open research question.  If P does equal NP, then computers will have much greater power and can solve many hard problems efficiently.

Computer Science Dept. Summer 2015: August 4 CS 146: Data Structures and Algorithms © R. Mak 36 Is P = NP? cont’d  The Clay Institute in 2000 listed seven Millennium Problems and offered $1 million for each solution: 1. Birch and Swinnerton-Dyer conjecture 2. Hodge conjecture 3. Navier-Stokes equations 4. P versus NP 5. Poincaré hypothesis (solved by Grigori Perelman in 2003) 6. Rieman hypothesis 7. Yang-Mills theory

Computer Science Dept. Summer 2015: August 4 CS 146: Data Structures and Algorithms © R. Mak 37 Is P = NP? cont’d  Donald Knuth has offered a live turkey to the first person who proves that P = NP. Therefore, if you prove it, you win one million dollars and a live turkey. Exponential time problems Towers of Hanoi NP problems NP-complete problems Traveling salesman P problems Sorting

Computer Science Dept. Summer 2015: August 4 CS 146: Data Structures and Algorithms © R. Mak 38 Review for the Final  The final exam will be Thursday, August 6 Same room, same time.  It will cover the entire semester, with emphasis on the second half. See the June 30 lecture notes for a review of the first half.  Same format as the midterm. Open book, notes, laptops, Internet.

Computer Science Dept. Summer 2015: August 4 CS 146: Data Structures and Algorithms © R. Mak 39 Sorting  Insertion sort  Shellsort Choices for gap sequence.  Heap sort  Merge sort Array and linked list versions External magnetic tapes

Computer Science Dept. Summer 2015: August 4 CS 146: Data Structures and Algorithms © R. Mak 40 Sorting, cont’d  Quicksort Partitioning strategies  Bucket sort and radix sort Card sorter  Analysis of sorting algorithms General lower bound for sorting

Computer Science Dept. Summer 2015: August 4 CS 146: Data Structures and Algorithms © R. Mak 41 Disjoint Set Class  Equivalence problem Relations Equivalence class  Find Path compression  Union Smart union

Computer Science Dept. Summer 2015: August 4 CS 146: Data Structures and Algorithms © R. Mak 42 Disjoint Set Class, cont’d  Applications Maze generation Kruskal’s algorithm

Computer Science Dept. Summer 2015: August 4 CS 146: Data Structures and Algorithms © R. Mak 43 Graphs  Representation Adjacency list  Topological sort Perform using a queue  Shortest path algorithms Unweighted shortest path Weighted least cost path Dijkstra’s algorithm

Computer Science Dept. Summer 2015: August 4 CS 146: Data Structures and Algorithms © R. Mak 44 Graphs, cont’d  Minimum spanning tree Prim’s algorithm Kruskal’s algorithm  Graph traversal algorithms Depth-first Breadth-first

Computer Science Dept. Summer 2015: August 4 CS 146: Data Structures and Algorithms © R. Mak 45 Hash Tables  Mapping function  Collision resolution Linked list Linear probing  Primary clustering Quadratic probing Double hashing

Computer Science Dept. Summer 2015: August 4 CS 146: Data Structures and Algorithms © R. Mak 46 Hash Tables, cont’d  Load factor  Rehashing  Java support for hashing

Computer Science Dept. Summer 2015: August 4 CS 146: Data Structures and Algorithms © R. Mak 47 Greedy Algorithms  Proceed in stages  Local optimum  Global optimum  Examples Dijkstra’s algorithm Prim’s algorithm Kruskal’s algorithm Job scheduling Huffman’s algorithm

Computer Science Dept. Summer 2015: August 4 CS 146: Data Structures and Algorithms © R. Mak 48 Divide and Conquer Algorithms  Divide problems into subproblems.  Conquer by combining the subproblem solutions.  Examples Towers of Hanoi Merge sort Quicksort Multiplying two large integers

Computer Science Dept. Summer 2015: August 4 CS 146: Data Structures and Algorithms © R. Mak 49 Dynamic Programming  Break a problem into subproblems. Solve them all and store the results. Use the stored results to solve the larger problem.  Use a table instead of recursion.  Examples: Fibonacci series Knapsack problem Ordering matrix multiplications

Computer Science Dept. Summer 2015: August 4 CS 146: Data Structures and Algorithms © R. Mak Longest Common Subsequence (LCS)  Recursive algorithm  Dynamic programming algorithm 50

Computer Science Dept. Summer 2015: August 4 CS 146: Data Structures and Algorithms © R. Mak 51 String Pattern Matching Algorithms  How many character-by-character comparisons?  Brute search Backtracking after a “false start” O(MN) comparisons  Knuth-Morris-Pratt algorithm Eliminates backtracking Find similar subpatterns in the pattern O(M+N) comparisons

Computer Science Dept. Summer 2015: August 4 CS 146: Data Structures and Algorithms © R. Mak 52 P = NP?  Hard and easy problems to solve.  Reductions  Class P  Class NP  NP-complete  Is P = NP?