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

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

P, NP, NP-Complete, and NPhard

Design and Analysis of Algorithms

Limitations of Algorithm Power

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

Computational Complexity

CS/COE

Computational complexity theory

Chapter 34: NP-Completeness

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

Theory of Computation Chapter 1: Introduction

Computational complexity theory

NP Complete Problems. COMP 215 Lecture 20

Running Time Evaluation

3. Algorithms. What matters? How fast do we solve the problem? How much computer resource do we need?

ICS 252 Introduction to Computer Design

CMSC 441: Algorithms. NP Completeness

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

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

ECS122A Handout on NP-Completeness March 12, 2018

Analysis of Algorithms

CSE 105 THEORY OF COMPUTATION

NP-Completeness. NP-Completeness 1

Turing Machines and Time Complexity

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

Theory of Computation CS3102 Spring 2014 A tale of computers, math, problem solving, life, love and tragic death

Analysis of Algorithm Efficiency. Dr. Yingwu Zhu

CSCE 222 Discrete Structures for Computing

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

Analysis of Algorithms. Unit 5 - Intractable Problems

Growth of Functions (CLRS 2.3,3)

NP-Completeness. Andreas Klappenecker. [based on slides by Prof. Welch]

NP-Completeness I. Lecture Overview Introduction: Reduction and Expressiveness

CSE 105 THEORY OF COMPUTATION

VIII. NP-completeness

Example: Fib(N) = Fib(N-1) + Fib(N-2), Fib(1) = 0, Fib(2) = 1

Introduction to Complexity Theory

Data Structures in Java

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

Lecture 25: Cook s Theorem (1997) Steven Skiena. skiena

Analysis of Algorithms [Reading: CLRS 2.2, 3] Laura Toma, csci2200, Bowdoin College

Algorithms and Their Complexity

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

Agenda. What is a complexity class? What are the important complexity classes? How do you prove an algorithm is in a certain class

Analysis of Algorithms

NP Completeness and Approximation Algorithms

Unit 1A: Computational Complexity

CSED233: Data Structures (2017F) Lecture4: Analysis of Algorithms

Tractable & Intractable Problems

Notes for Lecture 21

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)).

CS481: Bioinformatics Algorithms

NP-completeness. Chapter 34. Sergey Bereg

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

Time Complexity. CS60001: Foundations of Computing Science

CSC Design and Analysis of Algorithms. Lecture 1

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

Algorithms. Outline! Approximation Algorithms. The class APX. The intelligence behind the hardware. ! Based on

Copyright 2000, Kevin Wayne 1

Computational Complexity

Multiple Sequence Alignment: Complexity, Gunnar Klau, January 12, 2006, 12:

P vs. NP. Data Structures and Algorithms CSE AU 1

NP-Completeness. f(n) \ n n sec sec sec. n sec 24.3 sec 5.2 mins. 2 n sec 17.9 mins 35.

CSE 105 THEORY OF COMPUTATION

Harvard CS 121 and CSCI E-121 Lecture 22: The P vs. NP Question and NP-completeness

Admin NP-COMPLETE PROBLEMS. Run-time analysis. Tractable vs. intractable problems 5/2/13. What is a tractable problem?

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

CS 583: Algorithms. NP Completeness Ch 34. Intractability

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

Defining Efficiency. 2: Analysis. Efficiency. Measuring efficiency. CSE 421: Intro Algorithms. Summer 2007 Larry Ruzzo

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

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

Graph Theory and Optimization Computational Complexity (in brief)

Informatique Fondamentale IMA S8

Nondeterministic Polynomial Time

Algorithm Analysis, Asymptotic notations CISC4080 CIS, Fordham Univ. Instructor: X. Zhang

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

Ch 01. Analysis of Algorithms

Great Theoretical Ideas in Computer Science. Lecture 9: Introduction to Computational Complexity

Introduction. An Introduction to Algorithms and Data Structures

Computational Complexity

P is the class of problems for which there are algorithms that solve the problem in time O(n k ) for some constant k.

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

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

Define Efficiency. 2: Analysis. Efficiency. Measuring efficiency. CSE 417: Algorithms and Computational Complexity. Winter 2007 Larry Ruzzo

The P-vs-NP problem. Andrés E. Caicedo. September 10, 2011

Computer Sciences Department

CSE332: Data Structures & Parallelism Lecture 2: Algorithm Analysis. Ruth Anderson Winter 2019

Computer Algorithms CISC4080 CIS, Fordham Univ. Outline. Last class. Instructor: X. Zhang Lecture 2

Computer Algorithms CISC4080 CIS, Fordham Univ. Instructor: X. Zhang Lecture 2

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

Computers and Intractability. The Bandersnatch problem. The Bandersnatch problem. The Bandersnatch problem. A Guide to the Theory of NP-Completeness

SAT, Coloring, Hamiltonian Cycle, TSP

Ch01. Analysis of Algorithms

CS 4407 Algorithms Lecture 2: Iterative and Divide and Conquer Algorithms

CSL 356: Analysis and Design of Algorithms. Ragesh Jaiswal CSE, IIT Delhi

Computers and Intractability

NP-Complete Reductions 1

COMP/MATH 300 Topics for Spring 2017 June 5, Review and Regular Languages

CS 4407 Algorithms Lecture 2: Growth Functions

Transcription:

Algorithms Grad Refresher Course 2011 University of British Columbia Ron Maharik maharik@cs.ubc.ca

About this talk For those incoming grad students who Do not have a CS background, or Have a CS background from a long time ago Discuss some fundamental concepts from algorithms and CS theory Ease the transition into any grad-level CS course Based on the 2009 version by Brad Bingham Some slides used from MIT OpenCourseWare

UBC CS Theory Courses (UGrad) CPSC 320: Intermediate Algorithm Design and Analysis CPSC 421: Intro to Theory of Computing Required for CS undergrads Offered in term 1 (Belleville) and term 2 (Meyer) Offered in term 1 (Friedman) CSPC 420: Advanced Alg. Design & Analysis Offered in term 2 (Kirkpatrick)

Outline Asymptotic Notation and Analysis Graphs and algorithms NP-Completeness & undecidability Resources to Learn More

Pseudocode How do we analyze algorithms? Start with a pseudocode description! Specifies an algorithm mathematically Independent of hardware details, programming languages, etc. Reason about scalability in a mathematical way

How to Analyze? Count operations in the Random Access Machine (RAM) model: Single processor Infinite memory, constant time reads/writes Reasonable instruction set www8.cs.umu.se/kurser/tdbafl/vt06/algorithms/book/book/node12.htm Asymptotically (Big-O) Scenarios: worst case, average case What to analyze: time complexity, space complexity

Big-O Notation O(f(n)) is a set of functions g n O f n there exist constants c, n0 such that g n c f n for all n n0 In words: for sufficiently large inputs, the function g(n) is dominated by a scaled f(n) An upper bound, in an asymptotic sense Usually, g(n) is a complicated expression and f(n) is simple

Big-O: Illustration

Big-O Example 1 2 2 n 3n Show that is O n 2 i.e., find constants c and n0 where 1 2 2 n 3n c n, n n0 2 Solution: choose c=1, solve for n: 1 2 2 n 3n n 6 n n0=6 2 In general, ignore constants and drop lower order terms. For example: 4 3 4 2n 6n 100n 27 is O n

Big-Omega, Big-Theta g n f n there exist constants c, n0 such that g n c f n for all n n0 In words: for sufficiently large inputs, the function g(n) dominates a scaled f(n) A lower bound, in an asymptotic sense g n f n if g n O f n and g n f n A tight asymptotic bound

Complexity Food Chain Name Expression Constant O(1) Logarithmic O(log(n)) Linear O(n) Linearithmic O(n log(n)) Quadratic O(n2) Polynomial O(np) Exponential O(2n)

Traveling Salesman Problem (TSP) The run time of Dijkstra's algorithm in O(n2) with naïve data structures. This is polynomial, so we say the shortest-path problem can be solved in polynomial time. What about the following (similar) problem? Given a directed graph with edge weights, find a path that 1) Visits all vertices, and 2) Minimizes the path weight (sum of edges) There is no known algorithm for solving this in polynomial time. Why? TSP is NP-complete.

Knapsack Problem

NP-Completeness NP-complete problems are a class of problems for which there is no known algorithm that run in O(n k) time, for any constant k Equivalently, all known algorithms for solving NPcomplete problems are likely to be unacceptably slow If such an algorithm is found, or proven to not to exist, this solves the famous P=NP? question (such a proof is worth $1 Million USD) NP-complete problems are verifiable in polynomial time NP-hard: problems that are at least as hard as NPcomplete

NP-Completeness How do I prove that problem X is NP-complete? Show that candidate solutions for X can be checked in polynomial time; Show that there exists an NP-complete problem Y such that an algorithm that solves X can also solve Y. This is called a reduction. A reduction establishes that a fast solution for X would also give a fast solution for Y. The first established NP-complete problem was boolean satisfiability, or SAT. This is called Cook's Theorem (1971). If your problem is NP-complete, you can safely give up looking for an efficient, exact algorithm.

Graph Coloring Given an undirected graph, color each vertex such that no two vertices of the same color share an edge. What is the fewest number of colors that can be used? Checking Is a graph colorable using 2 colors? is easy, and solvable in polynomial time. Checking Is a graph colorable using 3 colors? is NP-complete.

Undecidability Even worse than NP-complete, undecidable problems are those for which no algorithm can exist that is guaranteed to always solve it correctly. Example 1: the halting problem: Will my problem ever stop executing? Example 2: Kolmogorov complexity: What is the simplest program that can generate a given string? Problems can be shown to be undecidable by using similar reductions as for NPcompleteness proofs.

Graph Traversal BFS and DFS http://eecourses.technion.ac.il/044268/

To learn more... Books: Harel Algorithmics (2004) Cormen et al. Introduction to Algorithms (2001) accessible and easy to read The comprehensive algorithms bible Often abbreviated as CLR or CLRS Garey and Johnson Computers and Intractability: A Guide to the Theory of NPCompleteness (1979)

To learn more... Courses: CPSC 320, 421, 500, 506 People: BETA Lab These slides: http://www.cs.ubc.ca/ ~ankgupta/refresher2011.html