Analysis of algorithms Richard Kelley. welcome!  You’re in SEM 261.  This is analysis of algorithms  Please make sure you’re in the right place.

Slides:



Advertisements
Similar presentations
MATH 224 – Discrete Mathematics
Advertisements

Lecture 12: Revision Lecture Dr John Levine Algorithms and Complexity March 27th 2006.
CS112: Course Overview George Mason University. Today’s topics Go over the syllabus Go over resources – Marmoset – Blackboard – Piazza – Textbook Highlight.
CSE 5522: Survey of Artificial Intelligence II: Advanced Techniques Instructor: Alan Ritter TA: Fan Yang.
January 5, 2015CS21 Lecture 11 CS21 Decidability and Tractability Lecture 1 January 5, 2015.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2001 Midterm Review Fri. Oct 26.
Intro to CIT 594
June 13, Introduction to CS II Data Structures Hongwei Xi Comp. Sci. Dept. Boston University.
CS503: First Lecture, Fall 2008 Michael Barnathan.
Hardness Results for Problems P: Class of “easy to solve” problems Absolute hardness results Relative hardness results –Reduction technique.
COMP 14 – 02: Introduction to Programming Andrew Leaver-Fay August 31, 2005 Monday/Wednesday 3-4:15 pm Peabody 217 Friday 3-3:50pm Peabody 217.
Hardness Results for Problems
July 16, Introduction to CS II Data Structures Hongwei Xi Comp. Sci. Dept. Boston University.
Computer Science 102 Data Structures and Algorithms V Fall 2009 Lecture 1: administrative details Professor: Evan Korth New York University 1.
Welcome to CompSci 100! As You Arrive… Make sure you grab a syllabus packet. Read through it. I will be covering the most essential points in my talk,
February 17, 2015Applied Discrete Mathematics Week 3: Algorithms 1 Double Summations Table 2 in 4 th Edition: Section th Edition: Section th.
CS211: Course Overview George Mason University. Today’s topics Go over the syllabus Go over resources – Marmoset – Piazza – Textbook Highlight important.
Mixed-level English classrooms What my paper is about: Basically my paper is about confirming with my research that the use of technology in the classroom.
Welcome to CS 115! Introduction to Programming. Class URL Please write this down!
Overview of the Course. Critical Facts Welcome to CISC 672 — Advanced Compiler Construction Instructor: Dr. John Cavazos Office.
Teaching Teaching Discrete Mathematics and Algorithms & Data Structures Online G.MirkowskaPJIIT.
CS223 Algorithms D-Term 2013 Instructor: Mohamed Eltabakh WPI, CS Introduction Slide 1.
MAT 331 Mathematical solving problem with computers.
COMP Introduction to Programming Yi Hong May 13, 2015.
CS 103 Discrete Structures Lecture 01 Introduction to the Course
CSc 2310 Principles of Programming (Java) Dr. Xiaolin Hu.
DISCRETE MATHEMATICS I CHAPTER 11 Dr. Adam Anthony Spring 2011 Some material adapted from lecture notes provided by Dr. Chungsim Han and Dr. Sam Lomonaco.
Welcome to CS 115! Introduction to Programming. Class URL
Fundamentals of Algorithms MCS - 2 Lecture # 1
Course Web Page Most information about the course (including the syllabus) will be posted on the course wiki:
CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 4.
Introduction Algorithms and Conventions The design and analysis of algorithms is the core subject matter of Computer Science. Given a problem, we want.
Computer Programming TCP1224 Chapter 3 Completing the Problem-Solving Process and Getting Started with C++
CSCI 51 Introduction to Computer Science Dr. Joshua Stough January 20, 2009.
Welcome to CS 115! Introduction to Programming. Class URL Write this down!
ISC/GAM 4322 ISC 6310 Multimedia Development and Programming Introduction.
Computer Science 102 Data Structures and Algorithms CSCI-UA.0102 Fall 2012 Lecture 1: administrative details Professor: Evan Korth New York University.
Major objective of this course is: Design and analysis of modern algorithms Different variants Accuracy Efficiency Comparing efficiencies Motivation thinking.
Principles of Computer Science I Honors Section Note Set 1 CSE 1341 – H 1.
Lecture 11 Data Structures, Algorithms & Complexity Introduction Dr Kevin Casey BSc, MSc, PhD GRIFFITH COLLEGE DUBLIN.
NP-COMPLETE PROBLEMS. Admin  Two more assignments…  No office hours on tomorrow.
Sorting: Implementation Fundamental Data Structures and Algorithms Klaus Sutner February 24, 2004.
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.
BIT 143: Programming – Data Structures It is assumed that you will also be present for the slideshow for the first day of class. Between that slideshow.
CSE 311 Foundations of Computing I Lecture 28 Computability: Other Undecidable Problems Autumn 2011 CSE 3111.
1 CS 381 Introduction to Discrete Structures Lecture #1 Syllabus Week 1.
CES 512 Theory of Software Systems B. Ravikumar (Ravi) Office: 141 Darwin Hall Course Web site:
CES 592 Theory of Software Systems B. Ravikumar (Ravi) Office: 124 Darwin Hall.
CS112: Course Overview George Mason University. Today’s topics Go over the syllabus Go over resources – Marmoset – Blackboard – Piazza – Textbook Highlight.
Data Structures and Algorithms in Java AlaaEddin 2012.
DATA STRUCTURES (CS212D) Overview & Review Instructor Information 2  Instructor Information:  Dr. Radwa El Shawi  Room: 
Onlinedeeneislam.blogspot.com1 Design and Analysis of Algorithms Slide # 1 Download From
Analysis of Algorithms: Math Review Richard Kelley, Lecture 2.
BITS Pilani Pilani Campus Data Structure and Algorithms Design Dr. Maheswari Karthikeyan Lecture1.
BIT 115: Introduction To Programming. 2 Today Midterm feedback Getting User Input.
Algorithm Complexity is concerned about how fast or slow particular algorithm performs.
Advanced Algorithms Analysis and Design
Introduction to Programming
Big-O notation.
Computer Science 102 Data Structures CSCI-UA
Welcome to CS 1010! Algorithmic Problem Solving.
Welcome to CS 1010! Algorithmic Problem Solving.
Definition In simple terms, an algorithm is a series of instructions to solve a problem (complete a task) We focus on Deterministic Algorithms Under the.
Welcome to CS 1340! Computing for scientists.
Welcome to CS 1010! Algorithmic Problem Solving.
Objective of This Course
Applied Discrete Mathematics Week 6: Computation
Design and Analysis of Algorithms
COMP 122 – Design and Analysis of Algorithms
Presentation transcript:

analysis of algorithms Richard Kelley

welcome!  You’re in SEM 261.  This is analysis of algorithms  Please make sure you’re in the right place.

administrivia  We have to get through some boring stuff today.  Class Policies  course webpages  who I am  textbooks  homework  quizzes & exams  we’ll also do a little bit of fun stuff.  No heavy lifting today.

course webpage & syllabus  The main course page is  You’ll find the following there:  Syllabus  Schedule  Slides  Example Programs  Possibly other sites, as demand dictates  Code submission?  Blog with lecture notes?

meet the course staff  I’m Richard Kelley  call me Richard  PhD Student – don’t call me “Dr” or “Professor”  Social Artificial Intelligence & Machine Learning  Robotics  Multiagent Systems  I took this class as an undergrad at UW.  I’ve TA’ed for this class for a few years here.

textbooks  no required text  two (highly) recommended texts:  Algorithm Design by Kleinberg & Tardos  Introduction to Algorithms by Cormen, et. al.

instead of required textbooks  my slides  slides from previous semesters  links to online resources  videos  short notes  sample programs  all available from the course website.  when I use a resource, I will point you to it.

homework  regularly assigned  I’m aiming for at least one per week  some really easy  as in, “make sure you can compile this program.”  some more involved  programming  writing  English exposition  proofs  first (easy) one today... maybe.  Linux only 

quizzes and exams  necessary evil  regular quizzes to make sure you’re paying attention  these should be easy, count as participation  a midterm  about half way through the material  a final  comprehensive

grading  homework (55% of your grade)  some theory  some programming  some writing  midterm (15% of your grade)  final (25% of your grade)  attendance & participation (5% of your grade)  short quizzes

what’s this course about?  we want to write good programs.  most advanced courses you take cover topics  operating systems  networking  graphics  robotics  some courses are about the processes that lead to better code  human-computer interaction  software engineering  the goal is that at the end of this course, your programs will be better  regardless of topic  regardless of process

what is a good program?  I know it when I see it?  some common qualities  easy to read  easy to modify  lots of tests  correct!  fast  no memory leaks

what’s wrong with these measures?  nothing!  but we’re going to focus (mostly) on the last two.  we want to write programs that are fast.  we want to write programs that use little memory.  we’re going to take a slightly more general view, though.

not programs. algorithms.  it turns out that focusing on programs is a bad idea.  computers tend to get faster over time.  one way to make your program faster is to buy a better machine.  although faster machines are good, we can do better if we’re more careful in our design.  this means choosing better algorithms

what is an algorithm?  we can be really picky here  but we won’t be  for our purposes, an algorithm is  a step-by-step process for a well-defined problem  takes zero or more inputs  produces zero or more outputs  is finite  is clearly defined  we’ll use pseudocode to describe algorithms

what is a good algorithm?  most problems can be solved in many different ways, using many different algorithms.  some algorithms are better than others  faster or more space efficient  we want to choose the “best” algorithms  let’s focus on time and try to work out what this means.  (I’m following Kleinberg & Tardos in this process)

why time?  even though there are a few quantities we want to optimize our program for, we’re going to spend most of our energy on running time.  this is pretty standard.  many of the ideas here carry over to other types of analysis.

basic notation  we need to have notation for  the size of an input  the running time of the algorithm  we’ll use variables like n and m to talk about input sizes.  we focus on input sizes instead of inputs  running time often depends more on the size of the input than the actual value of the input.  we’ll use T( ) to talk about running times.  for example, T(n) is the running time of an algorithm on an input of size n.

attempt 1: good means fast  idea: implement the algorithm. run it on some inputs, record the times  this is acceptable in some cases  in the real world, profiling our programs is a common optimization.  this approach has fundamental limitations that we want to (and can easily) avoid.  at least one homework assignment will involve this kind of analysis though.

why does this fail?  problems:  sensitive to the computer we run on  sensitive to the quality of our implementation  sensitive to the inputs we choose  doesn’t tell us how running time scales with increasing problem sizes.  scale:  if I run two different algorithms on inputs of size one, and then I run them on inputs of size two, how much longer do things take?  rather than look at implementations, we need to think mathematically.

attempt 2: better than brute force  let’s start by making an agreement:  we will focus on worst-case performance.  we want to find a bound on the largest possible running time an algorithm could have, over all inputs of size n.  this has a nice property:  not sensitive to inputs we choose.  next, let’s define “good” as “better than a brute-force search through all possible solutions.”

brute-force search  most problems have a natural “solution space”  sorting  path finding in graphs  most optimization problems  with discrete (finite) problems, we can often just look at every possible solution to see if it’s what we want.  this is usually not tractable.  solution spaces tend to grow quickly  in sorting, brute force requires looking at n! possible arrangements.

what’s wrong with this definition?  “good” as “better than brute force” is certainly better than our first attempt, but it’s not perfect.  main problem  it’s too vague  we solve vagueness by making our definition more mathematical.

attempt 3: polynomial time  in brute-force search, when we increase the problem size by one, we increase the number of possibilities multiplicatively.  in sorting, we go from n! to (n+1)!  a good algorithm should scale better.  if we double the input size, we’d like the algorithm to slow down by only a constant factor.  we get this behavior by agreeing that good algorithms are efficient, and  an algorithm is efficient if its running time is bounded above by some fixed polynomial.

terminology  if an algorithm’s running time is bounded above by a fixed polynomial, we may say:  the algorithm has a polynomial running time.  the algorithm runs in polynomial time.  the algorithm is a polynomial-time algorithm.  if a problem has an algorithmic solution that runs in polynomial time, we might say:  the problem is in the complexity class P.  the problem is in P.  For instance, you probably know that sorting is in P.  bubble sort’s running time is bounded above by n^10.

our goal: revised  based on this discussion, we can be more precise about the main goals of this course:  we want to find polynomial-time algorithms for important problems.  we want to be able to prove that our algorithms run in polynomial time.  we also want to answer the questions  are there interesting problems (that are solvable) that are not in P?  for such problems, what do we do?

extras  this is a theory course  I’ll provide opportunities to delve into more theoretical items as the course progresses.  optional for undergrads, less optional for grads.  this is a practical course  you should be able to use this stuff every day.  most of what we’re learning is at the core of the C++ standard library & the boost library.  as the course progresses, we’re going to learn how to use the standard library to do a lot for us.  we’re also going to cover C++11 (the standard formerly known as C++0x)  algorithmic portions only – no variadic template craziness.

the schedule: main topics  basics  mathematical foundations  basic analysis  easy problems  graph algorithms  (discrete) optimization – dynamic programming & greedy  hard problems  intractability  randomness and approximation  concurrency

other stuff  we’ll cover a few topics that are not directly related to algorithms, but are useful to know.  unit testing – to make grading easier.  profiling – to figure out what parts of your program are taking so long.  static & dynamic analysis tools – to find bugs and general badness in your code.

extra #1: std::vector  assignment #0  full instructions online  download assignment0.cpp from the course webpage.  make sure you can compile it.  the program illustrates the use of std::vector, which you can think of as a dynamically-resizable array.  you should get in the habit of using std::vector whenever you need a contiguous block of storage.  basic usage is similar to arrays, and is illustrated in the program.  from now on in this class, no more raw arrays.

next time: math review  hopefully I’ve convinced you that we need to do some math.  the next few lectures will review the most important ideas and techniques that we have to apply to prove that algorithms run in polynomial time.  also, assignment 0 is due. Assuming we can get g++ to work in the ECC.  Questions?