Data Structures in Java. Session 22 Instructor: Bert Huang

Similar documents
Data Structures and Algorithms

Data Structures in Java

Algorithms and Theory of Computation. Lecture 22: NP-Completeness (2)

Circuits. CSE 373 Data Structures

CMSC 441: Algorithms. NP Completeness

Design and Analysis of Algorithms

CSC 1700 Analysis of Algorithms: P and NP Problems

Data Structures and Algorithms

VIII. NP-completeness

COSE215: Theory of Computation. Lecture 20 P, NP, and NP-Complete Problems

CSE 326: Data Structures NP Completeness

CS 583: Algorithms. NP Completeness Ch 34. Intractability

CS 320, Fall Dr. Geri Georg, Instructor 320 NP 1

Topics in Complexity Theory

NP-Completeness. Until now we have been designing algorithms for specific problems

NP-complete problems. CSE 101: Design and Analysis of Algorithms Lecture 20

Limitations of Algorithm Power

8.3 Hamiltonian Paths and Circuits

NP-Completeness. CptS 223 Advanced Data Structures. Larry Holder School of Electrical Engineering and Computer Science Washington State University

} } } Lecture 23: Computational Complexity. Lecture Overview. Definitions: EXP R. uncomputable/ undecidable P C EXP C R = = Examples

NP Complete Problems. COMP 215 Lecture 20

NP Completeness. CS 374: Algorithms & Models of Computation, Spring Lecture 23. November 19, 2015

CS/COE

Approximation Algorithms

Intro to Contemporary Math

Analysis of Algorithms. Unit 5 - Intractable Problems

CSC 8301 Design & Analysis of Algorithms: Lower Bounds

The Complexity Classes P and NP. Andreas Klappenecker [partially based on slides by Professor Welch]

Tractability. Some problems are intractable: as they grow large, we are unable to solve them in reasonable time What constitutes reasonable time?

P, NP, NP-Complete. Ruth Anderson

CS 350 Algorithms and Complexity

COMP-330 Theory of Computation. Fall Prof. Claude Crépeau. Lecture 2 : Regular Expressions & DFAs

CS 350 Algorithms and Complexity

Lecture 24: How to become Famous with P and NP

SAT, Coloring, Hamiltonian Cycle, TSP

Hamiltonian Graphs Graphs

P and NP. Warm Up: Super Hard Problems. Overview. Problem Classification. Tools for classifying problems according to relative hardness.

Quantum Complexity Theory. Wim van Dam HP Labs MSRI UC Berkeley SQUINT 3 June 16, 2003

Hamiltonian Cycle. Zero Knowledge Proof

COSE215: Theory of Computation. Lecture 21 P, NP, and NP-Complete Problems

Correctness of Dijkstra s algorithm

Graduate Algorithms CS F-21 NP & Approximation Algorithms

NP-Complete and Non-Computable Problems. COMP385 Dr. Ken Williams

Complexity Theory Part II

CSCI FOUNDATIONS OF COMPUTER SCIENCE

1. Introduction Recap

Computer Science 385 Analysis of Algorithms Siena College Spring Topic Notes: Limitations of Algorithms

Instructor N.Sadagopan Scribe: P.Renjith. Lecture- Complexity Class- P and NP

ECS122A Handout on NP-Completeness March 12, 2018

Chapter 8. NP and Computational Intractability. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Polynomial-time Reductions

CS S-23 NP-Completeness and Undecidablity 1

1. (a) Explain the asymptotic notations used in algorithm analysis. (b) Prove that f(n)=0(h(n)) where f(n)=0(g(n)) and g(n)=0(h(n)).

Friday Four Square! Today at 4:15PM, Outside Gates

Optimization Prof. A. Goswami Department of Mathematics Indian Institute of Technology, Kharagpur. Lecture - 20 Travelling Salesman Problem

Tractable & Intractable Problems

Computational Complexity and Intractability: An Introduction to the Theory of NP. Chapter 9

Easy Problems vs. Hard Problems. CSE 421 Introduction to Algorithms Winter Is P a good definition of efficient? The class P

Algorithms. Grad Refresher Course 2011 University of British Columbia. Ron Maharik

NP-Completeness Part II

Computational Complexity

Algorithms Design & Analysis. Approximation Algorithm

CHAPTER 3 FUNDAMENTALS OF COMPUTATIONAL COMPLEXITY. E. Amaldi Foundations of Operations Research Politecnico di Milano 1

Automata Theory CS Complexity Theory I: Polynomial Time

The decision problem (entscheidungsproblem), halting problem, & Turing machines. CS 350 Fall 2018 gilray.org/classes/fall2018/cs350/

Lecture 15 - NP Completeness 1

Spring Lecture 21 NP-Complete Problems

CS 301: Complexity of Algorithms (Term I 2008) Alex Tiskin Harald Räcke. Hamiltonian Cycle. 8.5 Sequencing Problems. Directed Hamiltonian Cycle

/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: NP-Completeness I Date: 11/13/18

NP-Complete Problems. More reductions

P,NP, NP-Hard and NP-Complete

6.080 / Great Ideas in Theoretical Computer Science Spring 2008

Summer School on Introduction to Algorithms and Optimization Techniques July 4-12, 2017 Organized by ACMU, ISI and IEEE CEDA.

NP-Completeness. Subhash Suri. May 15, 2018

Welcome Back to Physics Electric Potential. Robert Millikan Physics 1308: General Physics II - Professor Jodi Cooley

NP and NP Completeness

Informatique Fondamentale IMA S8

ECS 120 Lesson 24 The Class N P, N P-complete Problems

Lecture 1: Course Overview and Turing machine complexity

The P versus NP Problem. Ker-I Ko. Stony Brook, New York

Chapter 8. NP and Computational Intractability

1 Computational Problems

NP and Computational Intractability

Lecture 4: NP and computational intractability

NP-Completeness. ch34 Hewett. Problem. Tractable Intractable Non-computable computationally infeasible super poly-time alg. sol. E.g.

Notes for Lecture Notes 2

P and NP. Inge Li Gørtz. Thank you to Kevin Wayne, Philip Bille and Paul Fischer for inspiration to slides

NP-Complete Problems and Approximation Algorithms

4/30/14. Chapter Sequencing Problems. NP and Computational Intractability. Hamiltonian Cycle

Notes for Lecture 21

The P = NP Problem Bristol Teachers Circle, June P.D.Welch, University of Bristol

Computational Complexity

CS Lecture 29 P, NP, and NP-Completeness. k ) for all k. Fall The class P. The class NP

More on NP and Reductions

NP Completeness and Approximation Algorithms

P P P NP-Hard: L is NP-hard if for all L NP, L L. Thus, if we could solve L in polynomial. Cook's Theorem and Reductions

Chapter 34: NP-Completeness

Undecidable Problems. Z. Sawa (TU Ostrava) Introd. to Theoretical Computer Science May 12, / 65

Computational Intractability 2010/4/15. Lecture 2

Algorithms and Data Structures Final Lesson

Transcription:

Data Structures in Java Session 22 Instructor: Bert Huang http://www.cs.columbia.edu/~bert/courses/33

Announcements Homework 5 solutions posted Homework 6 to be posted this weekend Final exam Thursday, Dec. 7 th, -7 PM, Hamilton 602 (this room) same format as midterm (open book/notes) Distinguished Lecture: Barbara Liskov, MIT. Turing Award Winner 2009. AM Monday. Davis Auditorium, CEPSR/Schapiro

Review Sorting Algorithm Examples External sorting* QuickSort space clarification

Todayʼs Plan Correction on external sorting Complexity Classes P, NP, NP-Complete, NP-Hard

External Sorting Disk 3 Disk 2 Disk Disk 0

External Sorting Disk 3 Disk 2 Disk Disk 0

External Sorting Disk 3 Disk 2 Disk Disk 0

External Sorting Disk 3 Disk 2 Disk Disk 0

External Sorting Disk 3 Disk 2 Disk Disk 0

Complexity of Problems Weʼve been concerned with the complexity of algorithms It is important to also consider the complexity of problems Understanding complexity is important for theory, and also for practice understanding the hardness of problems helps us build better algorithms

Three Graph Problems Euler Path: does a path exist that uses every edge exactly once? Hamiltonian Path: does a path exist that visits every node exactly once? Traveling Salesman: find the shortest path that visits every node exactly once?

Complexity Classes P - solvable in polynomial time NP - solvable in polynomial time by a nondeterministic computer i.e., you can check a solution in polynomial time NP-complete - a problem in NP such that any problem in NP is polynomially reducible to it Undecidable - no algorithm can solve the problem

Probable Complexity Class Hierarchy P NP NP-Complete NP-Hard Undecidable

Polynomial Time P All the algorithms we cover in class are solvable in polynomial time An algorithm that runs in polynomial time is considered efficient A problem solvable in polynomial time is considered tractable

Nondeterministic Polynomial Time NP Consider a magical nondeterministic computer infinitely parallel computer Equivalently, to solve any problem, check every possible solution in parallel return one that passes the check

NP-Complete Special class of NP problems that can be used to solve any other NP problem Hamiltonian Path, Satisfiability, Graph Coloring etc. NP-Complete problems can be reduced to other NP-Complete problems: polynomial time algorithm to convert the input and output of algorithms

NP-Hard A problem is NP-Hard if it is at least as complex as all NP-Complete problems NP-hard problems may not even be NP

Undecidable No algorithm can solve undecidable problems halting problem - given a computer program, determine if the computer program will finish Sketch of undecidability proof: Assume we have an algorithm that detects infinite loops Write program LOOP(P) that runs P on itself If P(P) halts, infinite loop, otherwise output

Halting Problem LOOP(P): If P(P) will halt: infinite loop If P(P) runs forever: output What happens if we call LOOP(LOOP)? LOOP(LOOP): If LOOP(LOOP) will halt: infinite loop If LOOP(LOOP) runs forever: output

P vs. NP So far, nobody has proven a super-polynomial lower bound on any NP-Complete problems, nor has anyone found a polynomial time algorithm for an NP-complete problem Therefore no problem is proven to be in one class but not the other; it is unknown if P and NP are the same

Complexity Class Hierarchy P? P? NP NP-Complete NP-Hard Undecidable

P Problems Most problems weʼve solved Proving a polynomial (or logarithmic) bound on any algorithm proves a problem is in P Euler paths - does a path exist that uses every edge? Return if there are zero or two nodes with odd degree.

Finding an Euler Circuit Run a partial DFS; search down a path until you need to backtrack (mark edges instead of nodes) At this point, you will have found a circuit Find first node along the circuit that has unvisited edges; run a DFS starting with that edge Splice the new circuit into the main circuit, repeat until all edges are visited

Euler Circuit Example 2 3 5 6 7

Euler Circuit Example 2 3 5 6 7

Euler Circuit Example 2 2 3 5 6 7

Euler Circuit Example 2 3 2 3 5 6 7

Euler Circuit Example 2 3 2 3 5 6 7

Euler Circuit Example 2 3 2 3 5 6 7

Euler Circuit Example 2 3 3 2 3 5 6 7

Euler Circuit Example 2 3 6 3 2 3 5 6 7

Euler Circuit Example 2 3 6 3 2 3 5 6 7

Euler Circuit Example 2 3 6 5 3 2 3 5 6 7

Euler Circuit Example 2 3 6 5 2 2 3 5 6 7 3

Euler Circuit Example 2 3 6 5 6 2 3 5 6 7 2 3

Euler Circuit Example 2 3 6 5 6 7 2 3 2 3 5 6 7

Euler Circuit Example 2 3 6 5 6 7 5 2 2 3 5 6 7 3

NP-Complete Problems Satisfiability Given Boolean expression of N variables, can we set variables to make expression true? First NP-Complete proof because Cookʼs Theorem gave polynomial time procedure to convert any NP problem to a Boolean expression I.e., if we have efficient algorithm for Satisfiability, we can efficiently solve any NP problem

NP-Complete Problems Graph Coloring Given a graph is it possible to color with k colors all nodes so no adjacent nodes are the same color? Coloring countries on a map Sudoku is a form of this problem. All squares in a row, column and blocks are connected. k = 9

NP-Complete Problems Hamiltonian Path Given a graph with N nodes, is there a path that visits each node exactly once?

NP-Hard Problems Traveling Salesman Closely related to Hamiltonian Path problem Given complete graph G, find the shortest path that visits all nodes If we are able to solve TSP, we can find a Hamiltonian Path; set connected edge weight to constant, disconnected to infinity TSP is NP-hard

http://www.tsp.gatech.edu/gallery/itours/usa3509.html

Reading Weiss 9.7 http://www.tsp.gatech.edu/