04/04/13 Algorithms and NP Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1.

Slides:



Advertisements
Similar presentations
CPE702 Complexity Classes Pruet Boonma Department of Computer Engineering Chiang Mai University Based on Material by Jenny Walter.
Advertisements

Design and Analysis of Algorithms NP-Completeness Haidong Xue Summer 2012, at GSU.
Fundamentals of Python: From First Programs Through Data Structures
Part 5. Computational Complexity (3)
CompSci 102 Discrete Math for Computer Science
Computational Complexity 1. Time Complexity 2. Space Complexity.
Lecture 8 Jianjun Hu Department of Computer Science and Engineering University of South Carolina CSCE350 Algorithms and Data Structure.
Computational problems, algorithms, runtime, hardness
Complexity Theory CSE 331 Section 2 James Daly. Reminders Project 4 is out Due Friday Dynamic programming project Homework 6 is out Due next week (on.
Analysis of Algorithms. Time and space To analyze an algorithm means: –developing a formula for predicting how fast an algorithm is, based on the size.
Algorithms. Problems, Algorithms, Programs Problem - a well defined task. –Sort a list of numbers. –Find a particular item in a list. –Find a winning.
Analysis of Algorithms CS 477/677
1 Algorithm Efficiency, Big O Notation, and Role of Data Structures/ADTs Algorithm Efficiency Big O Notation Role of Data Structures Abstract Data Types.
Algorithmic Complexity 2 Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Concept of Basic Time Complexity Problem size (Input size) Time complexity analysis.
CS 206 Introduction to Computer Science II 01 / 28 / 2009 Instructor: Michael Eckmann.
CS10 The Beauty and Joy of Computing Lecture #23 : Limits of Computing Thanks to the success of the Kinect, researchers all over the world believe.
Chapter 11 Limitations of Algorithm Power Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
Solution methods for Discrete Optimization Problems.
Algorithmic Complexity 3 Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Abstract Data Types (ADTs) Data Structures The Java Collections API
CSc /6 Week nine 1 CSc142 Algorithms and efficiency Week 9 Pete Bagnall Elizabeth Phillips
1.1 Chapter 1: Introduction What is the course all about? Problems, instances and algorithms Running time v.s. computational complexity General description.
1 Complexity Lecture Ref. Handout p
Programming & Data Structures
Chapter Complexity of Algorithms –Time Complexity –Understanding the complexity of Algorithms 1.
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
Discrete Mathematics Algorithms. Introduction  An algorithm is a finite set of instructions with the following characteristics:  Precision: steps are.
1 Chapter 24 Developing Efficient Algorithms. 2 Executing Time Suppose two algorithms perform the same task such as search (linear search vs. binary search)
Algorithm Efficiency CS 110: Data Structures and Algorithms First Semester,
1 Chapter 1 Analysis Basics. 2 Chapter Outline What is analysis? What to count and consider Mathematical background Rates of growth Tournament method.
Matt Schierholtz. Method for solving problems with finite steps Algorithm example: Error Check for problem Solve problem Must terminate.
COMPE 574 Fundamentals of Algorithms Spring Murat KARAKAYA Department of Computer Engineering.
Tonga Institute of Higher Education Design and Analysis of Algorithms IT 254 Lecture 8: Complexity Theory.
Chapter 12 Recursion, Complexity, and Searching and Sorting
Chapter 3 Sec 3.3 With Question/Answer Animations 1.
Introduction to Algorithms Lecture 1. Introduction The methods of algorithm design form one of the core practical technologies of computer science. The.
RESOURCES, TRADE-OFFS, AND LIMITATIONS Group 5 8/27/2014.
Algorithm Analysis PS5 due 11:59pm Wednesday, April 18 Final Project Phase 2 (Program Outline) due 1:30pm Tuesday, April 24 Wellesley College CS230.
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 
CSC 413/513: Intro to Algorithms NP Completeness.
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.
More Computational Complexity Shirley Moore CS4390/5390 Fall August 29,
P, NP, and Exponential Problems Should have had all this in CS 252 – Quick review Many problems have an exponential number of possibilities and we can.
Analysis of Algorithms [ Section 4.1 ] Examples of functions important in CS: the constant function:f(n) =
Cliff Shaffer Computer Science Computational Complexity.
3.3 Complexity of Algorithms
Algorithmic Analysis Charl du Plessis and Robert Ketteringham.
Beauty and Joy of Computing Limits of Computing Ivona Bezáková CS10: UC Berkeley, April 14, 2014 (Slides inspired by Dan Garcia’s slides.)
SNU OOPSLA Lab. 1 Great Ideas of CS with Java Part 1 WWW & Computer programming in the language Java Ch 1: The World Wide Web Ch 2: Watch out: Here comes.
CS10: The Beauty and Joy of Computing Lecture #22 Limits of Computing Warning sign posted at Stern Hall. Also, Apple releases new operating.
Limits to Computation How do you analyze a new algorithm? –Put it in the form of existing algorithms that you know the analysis. –For example, given 2.
LIMITATIONS OF ALGORITHM POWER
CPS Computational problems, algorithms, runtime, hardness (a ridiculously brief introduction to theoretical computer science) Vincent Conitzer.
Design and Analysis of Algorithms (09 Credits / 5 hours per week) Sixth Semester: Computer Science & Engineering M.B.Chandak
Complexity © 2014 Project Lead The Way, Inc.Computer Science and Software Engineering.
تصميم وتحليل الخوارزميات عال311 Chapter 3 Growth of Functions
CS 150: Analysis of Algorithms. Goals for this Unit Begin a focus on data structures and algorithms Understand the nature of the performance of algorithms.
CES 592 Theory of Software Systems B. Ravikumar (Ravi) Office: 124 Darwin Hall.
Review I. Final exam Date TBD. Don ’ t be late! Open book, open notes No calculators or any electronics Worth 50% of final grade.
David Luebke 1 2/18/2016 CS 332: Algorithms NP Completeness Continued: Reductions.
Optimization/Decision Problems Optimization Problems – An optimization problem is one which asks, “What is the optimal solution to problem X?” – Examples:
Big O David Kauchak cs302 Spring Administrative Assignment 1: how’d it go? Assignment 2: out soon… Lab code.
Chapter 9 Recursion © 2006 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.
Lecture. Today Problem set 9 out (due next Thursday) Topics: –Complexity Theory –Optimization versus Decision Problems –P and NP –Efficient Verification.
GC 211:Data Structures Week 2: Algorithm Analysis Tools Slides are borrowed from Mr. Mohammad Alqahtani.
Data Structures Lab Algorithm Animation.
Discrete Mathematics CS 2610
4-9问题的形式化描述.
Presentation transcript:

04/04/13 Algorithms and NP Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1

Outline Algorithms – Karatsuba multiplication (maybe) – Example of dynamically created arrays Algorithm complexity – Sublinear, linear, linearithmic, quadratic, cubic, exponential, factorial – Worst case vs. average case NP vs. Exponential 2

Administrative Mini-homework released yesterday Long-form homework – Problems released on website today – Moodle boxes available on Friday Note: mini-hw is long, and long-form homework is short Tests will be released next week’s discussion – Do not discuss with those who haven’t taken it yet 3

This class Review of algorithms and big-O – Computing factorial series – Multiplying large numbers The master theorem Algorithmic complexity P vs. NP 4

Example: factorialSeries.m 5 See code Lesson 1: Be careful of implementation details that hide computational complexity Lesson 2: Knowing complexity of algorithm can help find major implementation flaws

Master theorem 6

7 Leaf term dominates (hyper expansion) Each level costs the same (balanced expansion) Top node dominates (slow expansion)

Master theorem 8 Example algorithm: multiplying large numbers

Master theorem 9 Example algorithm: sorting

Master theorem 10

Example: multiplying large numbers 11 Complexity:

Example: multiplying large numbers 12 Complexity:

Algorithm complexity constant, sublinear, linear, linearithmic, quadratic, cubic, exponential, factorial 13 time problem size

Average-case vs. worst-case complexity Sometimes worst case is unlikely or avoidable – E.g., quicksort Average-case complexity describes behavior for a typical case 14

P vs. NP A problem is class P if a polynomial-time solution exists A problem is class NP (non-deterministic polynomial time) if a solution can be checked in polynomial time, but no known algorithm can generate the solution in polynomial time 15

Examples 16

Examples Sorting a set of integers How fast can you find a solution? How fast can you check a solution? P: sorting takes linearithmic time, and checking takes linear time 17

Examples 18

P = NP? 19

NP-complete and NP-hard 20

Examples Traveling salesman problem: determine an order of cities to visit that minimizes total travel time NP-hard: finding solution takes exponential time, checking solution is NP-complete 21

Things to remember Be able to analyze code for computational cost – Tools: finding loops and recursive calls, using recursion trees – Sometimes need to know inner-workings of a library to determine (e.g., factorialSeries) Be able to convert to big-O or big-Theta and be familiar with basic complexity terms – E.g., linear, nlogn, polynomial, exponential Problems in NP can be checked in polynomial time but probably not solved in polynomial time – P=NP is open problem, most think not 22