1 CSE 417: Algorithms and Computational Complexity Winter 2001 Instructor: Paul Beame TA: Gidon Shavit.

Slides:



Advertisements
Similar presentations
Heuristics, and what to do if you dont know what to do Carl Hultquist.
Advertisements

MEMORY popo.
Announcements You survived midterm 2! No Class / No Office hours Friday.
Algorithm and Complexity Analysis
Efficient access to TIN Regular square grid TIN Efficient access to TIN Let q := (x, y) be a point. We want to estimate an elevation at a point q: 1. should.
Problem Solving by Searching Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 3 Spring 2007.
Efficiency of Algorithms
CSE 373: Data Structures and Algorithms Lecture 5: Math Review/Asymptotic Analysis III 1.
Fundamentals of Python: From First Programs Through Data Structures
Chapter 10 Algorithmic Thinking. Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Learning Objectives List the five essential.
25 May Quick Sort (11.2) CSE 2011 Winter 2011.
What is an Algorithm? (And how do we analyze one?)
Introduction to Analysis of Algorithms
Efficiency of Algorithms
CPSC 411, Fall 2008: Set 1 1 CPSC 411 Design and Analysis of Algorithms Set 1: Introduction and Review Prof. Jennifer Welch Fall 2008.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 21 Instructor: Paul Beame.
CS107 Introduction to Computer Science
Implicit Hitting Set Problems Richard M. Karp Harvard University August 29, 2011.
CSE 830: Design and Theory of Algorithms
CSE 830: Design and Theory of Algorithms
Quicksort.
Cmpt-225 Algorithm Efficiency.
CSE 830: Design and Theory of Algorithms Dr. Eric Torng.
CS3381 Des & Anal of Alg ( SemA) City Univ of HK / Dept of CS / Helena Wong 2. Analysis of Algorithms - 1 Analysis.
1 Efficiency of Algorithms. 2  Two main issues related to the efficiency of algorithms:  Speed of algorithm  Efficient memory allocation  We will.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 6 Instructor: Paul Beame TA: Gidon Shavit.
Analysis of Algorithms 7/2/2015CS202 - Fundamentals of Computer Science II1.
The Traveling Salesperson Problem
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Instructor: Paul Beame TA: Gidon Shavit.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 25 Instructor: Paul Beame.
Solution methods for Discrete Optimization Problems.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 5 Instructor: Paul Beame TA: Gidon Shavit.
Design and Analysis of Algorithms
Analysis of Algorithms Spring 2015CS202 - Fundamentals of Computer Science II1.
HOW TO SOLVE IT? Algorithms. An Algorithm An algorithm is any well-defined (computational) procedure that takes some value, or set of values, as input.
Lecture 2 We have given O(n 3 ), O(n 2 ), O(nlogn) algorithms for the max sub-range problem. This time, a linear time algorithm! The idea is as follows:
Gary MarsdenSlide 1University of Cape Town Computer Architecture – Introduction Andrew Hutchinson & Gary Marsden (me) ( ) 2005.
Overview of Computing. Computer Science What is computer science? The systematic study of computing systems and computation. Contains theories for understanding.
Data Structures and Algorithms Lecture 5 and 6 Instructor: Quratulain Date: 15 th and 18 th September, 2009 Faculty of Computer Science, IBA.
Representing and Using Graphs
Analysis of algorithms Analysis of algorithms is the branch of computer science that studies the performance of algorithms, especially their run time.
Excursions in Modern Mathematics, 7e: Copyright © 2010 Pearson Education, Inc. 6 The Mathematics of Touring 6.1Hamilton Paths and Hamilton Circuits.
More Computational Complexity Shirley Moore CS4390/5390 Fall August 29,
What is an algorithm? Algorithms are the ideas behind computer programs. An algorithm is the thing which stays the same whether the program is in Pascal.
1Computer Sciences Department. Book: Introduction to Algorithms, by: Thomas H. Cormen Charles E. Leiserson Ronald L. Rivest Clifford Stein Electronic:
Introduction to Computer Architecture. What is binary? We use the decimal (base 10) number system Binary is the base 2 number system Ten different numbers.
Chapter 10 Algorithm Analysis.  Introduction  Generalizing Running Time  Doing a Timing Analysis  Big-Oh Notation  Analyzing Some Simple Programs.
New Mexico Computer Science For All Algorithm Analysis Maureen Psaila-Dombrowski.
Thursday, May 9 Heuristic Search: methods for solving difficult optimization problems Handouts: Lecture Notes See the introduction to the paper.
Review 1 Selection Sort Selection Sort Algorithm Time Complexity Best case Average case Worst case Examples.
CSCE 411 Design and Analysis of Algorithms Set 1: Introduction Slides by Prof. Jennifer Welch Spring 2014 CSCE 411, Spring 2013: Set 1 1.
CSCI1600: Embedded and Real Time Software Lecture 33: Worst Case Execution Time Steven Reiss, Fall 2015.
Section 13  Questions  Graphs. Graphs  A graph representation: –Adjacency matrix. Pros:? Cons:? –Neighbor lists. Pros:? Cons:?
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 23 Algorithm Efficiency.
27-Jan-16 Analysis of Algorithms. 2 Time and space To analyze an algorithm means: developing a formula for predicting how fast an algorithm is, based.
1 Ch. 2: Getting Started. 2 About this lecture Study a few simple algorithms for sorting – Insertion Sort – Selection Sort (Exercise) – Merge Sort Show.
CS 101 – Oct. 7 Solving simple problems: create algorithm Structure of solution –Sequence of steps (1,2,3….) –Sometimes we need to make a choice –Sometimes.
CSCE 411 Design and Analysis of Algorithms Set 1: Introduction and Review Prof. Jennifer Welch Spring 2012 CSCE 411, Spring 2012: Set 1 1.
Engineering Principles in Software Engineering Here are some key ideas you will learn about divide-and-conquer 2. recursion 3. greedy algorithms,
Analysis of Algorithms Spring 2016CS202 - Fundamentals of Computer Science II1.
Victoria Ibarra Mat:  Generally, Computer hardware is divided into four main functional areas. These are:  Input devices Input devices  Output.
Algorithm Complexity is concerned about how fast or slow particular algorithm performs.
May 26th –non-comparison sorting
Algorithm Analysis CSE 2011 Winter September 2018.
CSCE 411 Design and Analysis of Algorithms
Quicksort.
CSE 417: Algorithms and Computational Complexity
Estimating Algorithm Performance
Quicksort.
Presentation transcript:

1 CSE 417: Algorithms and Computational Complexity Winter 2001 Instructor: Paul Beame TA: Gidon Shavit

2 A problem  Printed circuit-board company has a robot arm that solders components to the board  Time to do it depends on  total distance the arm must move from initial rest position around the board and back to the initial positions  For each board design, must figure out good order to do the soldering

3 Printed Circuit Board

4

5 A well-defined Problem  Input: Given a set S of n points in the plane  Output: The shortest cycle tour that visits each point in the set S.  How might you solve it?

6 Nearest Neighbor Heuristic  Start at some point p 0  Walk first to its nearest neighbor p 1  Repeatedly walk to the nearest unvisited neighbor until all points have been visited  Then walk back to p 0

7 Nearest Neighbor Heuristic p0p0 p1p1 p6p6

8 An input where it works badly p0p

9 Revised idea - Closest Pairs first  Repeatedly pick the closest pair of points to join so that the result can still be part of a single loop in the end  pick endpoints of line segments already created  initially line segments consist of single points  choose the closest pair of these endpoints that lie on different segments.  How does this work on our bad example?

10 Another bad example 1 1.5

11 Another bad example  10 vs 3

12 Something that works  For each of the n! orderings of the points check the length of the cycle you get  Keep the best one

13 Efficiency  The two incorrect algorithms were greedy  they made choices and never reconsidered their choices  often it does not work  when it does the algorithms are typically efficient  Our correct algorithm is incredibly slow  20! is so large that counting to one billion in a second it would still take 2.4 billion seconds  (around 70 years!)

14 Measuring efficiency: The RAM model  RAM = Random Access Machine  Time  # of instructions executed in an ideal assembly language  each simple operation (+,*,-,=,if,call) takes one time step  each memory access takes one time step  No bound on the memory

15 We left out things but...  Things we’ve dropped  memory hierarchy  disk, caches, registers have many orders of magnitude differences in access time  not all instructions take the same time in practice  However,  the RAM model is very useful for understanding how to design algorithms and get a good sense of how quickly they will work  one can usually tune implementations so that the hierarchy etc is not a huge factor

16 What kind of analysis?  Problem size n  Worst-case complexity: max # steps algorithm takes on any input of size n  Best-case complexity: min # steps algorithm takes on any input of size n  Average-case complexity: avg # steps algorithm takes on inputs of size n

17 Pros and cons:  Best-case  unrealistic overselling  can tune an algorithm so it works on one easy input  guarantee isn’t comforting  Worst-case  a fast algorithm has a comforting guarantee  no way to cheat by hard-coding special cases  maybe too pessimistic  Average-case  over what distribution?  different people may have different average problems