Download presentation

Presentation is loading. Please wait.

Published byBarbra Kennedy Modified over 6 years ago

1
Complexity Theory CSE 331 Section 2 James Daly

2
Reminders Project 4 is out Due Friday Dynamic programming project Homework 6 is out Due next week (on the last day of class) Last homework Covers greedy algorithms and dynamic programming

3
Review: Sorting We discussed several sorting algorithms in class Insertion Sort Selection Sort Quick Sort Merge Sort Heap Sort Each has various tradeoffs Some are more efficient then others

4
Algorithm Theory An algorithm is a solution to a problem Some problems have no efficient algorithms to solve them Some problems have no solution at all The complexity of a problem is the complexity of the best algorithm for solving the problem Finding the max of an unsorted array: O(n) Comparison-based sorting: O(n log n)

5
Finite Automata (FA) Very simple machine Fixed number of states One starting state Some “accepting” states Reads a string one symbol at a time Moves to a new state based on the symbol Returns whether it ends in an accepting state

6
Example S A F 1 1 1 0 0 0 0100 Accept!

7
Example S A F 1 1 1 0 0 0 011 Reject!

8
Nondeterministic Finite Automata (NFA) Special type of FA States can have multiple transitions with the same symbol Takes all of them! Is in a superposition of states Accepts if any of them accept

9
Example ab * Accepts any string ending in ab

10
Turing Machine An idealized computer capable of running any program Only slightly more powerful than an actual computer (they have infinite memory) Also has deterministic and non-deterministic versions

11
Class P An algorithm runs in polynomial time if its running time is O(n k ) for some constant k Polynomial time is better than exponential time: O(2 n ) P is the class of problems solvable in polynomial time We consider these to have “efficient” solutions

12
Class NP Class of problems solvable in polynomial time on a non-deterministic machine Can be verified but not necessarily solved in polynomial time on a normal (deterministic) machine Does not stand for “non-polynomial”

13
Decision Problems Yes / No (Boolean) problem Can turn an optimization problem into a decision problem by adding a target number Example: Shortest path problem: Optimization problem Decision version: Is there a path of size k or less?

14
NP-Complete (NPC) Class of decision problems Properties Must be in class NP (verifiable in polynomial time) Must be in class NP-Hard (at least as difficult as anything in NP)

15
NP P NP-Hard NPC P ≠ NP NP-Hard P = NP = NPC P = NP

16
Completeness Theory If any NPC problem can be solved in polynomial time, then all NPC problems have polynomial time solutions (P = NP) Whether this is the case or not is unknown One of the most important open problems Millennium Prize: $1 million if you can answer it Most believe that P ≠ NP

17
Satisfiability (SAT)

18
Maximum Clique A clique is a sub-graph of G where each vertex shares an edge with every other vertex Maximum clique problem: find the clique containing the largest number of vertices in G Decision problem: does a clique of at least k vertices exist within G?

19
Maximum Clique

20
Knapsack problem You can carry up to k kg in your backpack There are a variety of items, each with some value and weight Maximize the value of the items you put in your bag 15 kg capacity $4 12 kg $2 2 kg $2 1 kg $1 1 kg $10 4 kg Value: $15, Weight: 7 kg

21
Travelling Salesman Problem Give a list of cities and roads between them (a graph), find the shortest tour that visits each city AB CD 20 34 12 42 30 35

22
Proving Hardness It is often helpful to prove a problem is NP- complete This is normally done by converting between problems If you can solve the new problem, you can solve the original

23
Proving Hardness If you can convert from an NP-complete problem to your problem, it must be NP-hard. If you can also convert back, then it is NP- complete

24
Maximum Independent Set (MIS) In a graph, an independent set is a set of vertices where no edge connects two vertices in the set. The MIS is the largest such set in the graph

25
Conversion Finding an independent set on G is the same as finding a clique on the complement of G (reversing whether edges exist) Since max clique is NP-complete, so is MIS Max CliqueMIS

Similar presentations

© 2021 SlidePlayer.com Inc.

All rights reserved.

To make this website work, we log user data and share it with processors. To use this website, you must agree to our Privacy Policy, including cookie policy.

Ads by Google