CSE 373 Data Structures and Algorithms

Slides:



Advertisements
Similar presentations
Md. Ahsan Arif, Assistant Professor, Dept. of CSE, AUB
Advertisements

CHAPTER 2 ALGORITHM ANALYSIS 【 Definition 】 An algorithm is a finite set of instructions that, if followed, accomplishes a particular task. In addition,
Lecture3: Algorithm Analysis Bohyung Han CSE, POSTECH CSED233: Data Structures (2014F)
Lecture: Algorithmic complexity
Fundamentals of Python: From First Programs Through Data Structures
Fall 2006CENG 7071 Algorithm Analysis. Fall 2006CENG 7072 Algorithmic Performance There are two aspects of algorithmic performance: Time Instructions.
Introduction to Analysis of Algorithms
Complexity Analysis (Part I)
CS107 Introduction to Computer Science
Complexity Analysis (Part I)
1 TCSS 342, Winter 2005 Lecture Notes Course Overview, Review of Math Concepts, Algorithm Analysis and Big-Oh Notation Weiss book, Chapter 5, pp
Analysis of Algorithms 7/2/2015CS202 - Fundamentals of Computer Science II1.
Elementary Data Structures and Algorithms
Analysis of Algorithms COMP171 Fall Analysis of Algorithms / Slide 2 Introduction * What is Algorithm? n a clearly specified set of simple instructions.
Analysis of Algorithms Spring 2015CS202 - Fundamentals of Computer Science II1.
Algorithm Analysis (Big O)
Week 2 CS 361: Advanced Data Structures and Algorithms
SEARCHING, SORTING, AND ASYMPTOTIC COMPLEXITY Lecture 12 CS2110 – Fall 2009.
Data Structures and Algorithms Lecture 5 and 6 Instructor: Quratulain Date: 15 th and 18 th September, 2009 Faculty of Computer Science, IBA.
1 Time Analysis Analyzing an algorithm = estimating the resources it requires. Time How long will it take to execute? Impossible to find exact value Depends.
Program Efficiency & Complexity Analysis. Algorithm Review An algorithm is a definite procedure for solving a problem in finite number of steps Algorithm.
CSE373: Data Structures and Algorithms Lecture 3: Math Review; Algorithm Analysis Lauren Milne Summer 2015.
CSC – 332 Data Structures Generics Analysis of Algorithms Dr. Curry Guinn.
Algorithm Analysis (Big O)
CSE 373: Data Structures and Algorithms
CSE 326: Data Structures Asymptotic Analysis Hannah Tang and Brian Tjaden Summer Quarter 2002.
1 Chapter 2 Algorithm Analysis Reading: Chapter 2.
Algorithm Analysis with Big Oh ©Rick Mercer. Two Searching Algorithms  Objectives  Analyze the efficiency of algorithms  Analyze two classic algorithms.
Analysis of Algorithms Spring 2016CS202 - Fundamentals of Computer Science II1.
Algorithm Analysis 1.
Complexity Analysis (Part I)
Introduction to Analysis of Algorithms
Analysis of Algorithms
Algorithmic complexity: Speed of algorithms
Introduction to Analysis of Algorithms
Analysis of Algorithms
Introduction to Algorithms
Introduction to Analysis of Algorithms
Complexity In examining algorithm efficiency we must understand the idea of complexity Space complexity Time Complexity.
CSE373: Data Structures and Algorithms Lecture 3: Math Review; Algorithm Analysis Catie Baker Spring 2015.
Introduction to Algorithms
Algorithm Analysis CSE 2011 Winter September 2018.
Course Description Algorithms are: Recipes for solving problems.
Algorithm Analysis (not included in any exams!)
CSE373: Data Structures and Algorithms Lecture 4: Asymptotic Analysis
Chapter 12: Analysis of Algorithms
Objective of This Course
ITEC 2620M Introduction to Data Structures
Introduction to Data Structures
Introduction to Algorithms Analysis
CS 201 Fundamental Structures of Computer Science
Analysis of Algorithms
Algorithmic complexity: Speed of algorithms
Analyzing an Algorithm Computing the Order of Magnitude Big O Notation
Searching, Sorting, and Asymptotic Complexity
CSE 373: Data Structures & Algorithms
CE 221 Data Structures and Algorithms
Introduction to Algorithm and its Complexity Lecture 1: 18 slides
CSE 373 Optional Section Led by Yuanwei, Luyi Apr
Algorithmic complexity: Speed of algorithms
CSC 380: Design and Analysis of Algorithms
Analysis of Algorithms
CS210- Lecture 2 Jun 2, 2005 Announcements Questions
Course Description Algorithms are: Recipes for solving problems.
CSE 373: Data Structures and Algorithms
Estimating Algorithm Performance
Complexity Analysis (Part I)
Analysis of Algorithms
Design and Analysis of Algorithms
Complexity Analysis (Part I)
Presentation transcript:

CSE 373 Data Structures and Algorithms Lecture 3: Introduction to Asymptotic Analysis

Why algorithm analysis? So much data!! Human genome: 3.2 * 109 base pairs If there are 7 * 109 on the planet, how many base pairs of human DNA? Earth surface area: 1.49 * 108 km2 How many photos if taking a photo of each m2? For every day of the year (3.65 * 102)? But aren't computers getting faster and faster?

Why algorithm analysis? As problem sizes get bigger, analysis is becoming more important. The difference between good and bad algorithms is getting bigger. Being able to analyze algorithms will help us identify good ones without having to program them and test them first.

Measuring Performance: Empirical Approach Implement it, run it, time it (averaging trials) Pros? No math! Cons? Need to implement code When comparing two algorithms, all other factors need to be held constant (e.g., same computer, OS, processor, load) A really bad algorithm could take a really long time to execute

Measuring Performance: Analytical Approach Use a simple model for basic operation costs Computational Model has all the basic operations: +, -, *, / , =, comparisons infinite memory all basic operations take exactly one time unit to execute analysis = determining run-time efficiency. model = estimate, not meant to represent everything in real-world

Measuring Performance: Analytical Approach Analyze steps of algorithm, estimating amount of work each step takes Pros? Independent of system-specific configuration Good for estimating Don't need to implement code Cons? Won't give you info exact runtimes optimizations made by the computer architecture Only gives useful information for large problem sizes In real life, not all operations take exactly the same time (multiplication takes longer than addition) and have memory limitations

Analyzing Performance General “rules” to help measure how long it takes to do things: Basic operations Consecutive statements Conditionals Loops Function calls Recursive functions Constant time Sum of number of statements Test, plus larger branch cost Sum of iterations Cost of function body Solve “recurrence relation”

Efficiency examples statement1; statement2; statement3; for (int i = 1; i <= N; i++) { statement4; } statement5; statement6; statement7; 4N + 3 3 N 3N

Efficiency examples 2 for (int i = 1; i <= N; i++) { for (int j = 1; j <= N; j++) { statement1; } statement2; statement3; statement4; statement5; How many statements will execute if N = 10? If N = 1000? N2 N2 + 4N 4N

Relative rates of growth Most algorithms' runtime can be expressed as a function of the input size N rate of growth: measure of how quickly the graph of a function rises Goal: distinguish between fast- and slow-growing functions We only care about very large input sizes (for small sizes, almost any algorithm is fast enough) This helps us discover which algorithms will run more quickly or slowly, for large input sizes Most of the time interested in worst case performance; sometimes look at best or average performance

Growth rate example Consider these graphs of functions. Perhaps each one represents an algorithm: n3 + 2n2 100n2 + 1000 Which grows faster?

Growth rate example How about now?