CSE 3358 NOTE SET 2 Data Structures and Algorithms 1.

Slides:



Advertisements
Similar presentations
CSE 373: Data Structures and Algorithms Lecture 5: Math Review/Asymptotic Analysis III 1.
Advertisements

Razdan with contribution from others 1 Algorithm Analysis What is the Big ‘O Bout? Anshuman Razdan Div of Computing.
Analysys & Complexity of Algorithms Big Oh Notation.
the fourth iteration of this loop is shown here
Fall 2006CENG 7071 Algorithm Analysis. Fall 2006CENG 7072 Algorithmic Performance There are two aspects of algorithmic performance: Time Instructions.
Asymptotic Growth Rate
Cutler/HeadGrowth of Functions 1 Asymptotic Growth Rate.
Introduction to Analysis of Algorithms
25 June 2015Comp 122, Spring 2004 Asymptotic Notation, Review of Functions & Summations.
CS2420: Lecture 4 Vladimir Kulyukin Computer Science Department Utah State University.
The Efficiency of Algorithms
CS 104 Introduction to Computer Science and Graphics Problems Data Structure & Algorithms (1) Asymptotic Complexity 10/28/2008 Yang Song.
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.
Algorithm Analysis (Big O)
Spring2012 Lecture#10 CSE 246 Data Structures and Algorithms.
COMP s1 Computing 2 Complexity
Asymptotic Notations Iterative Algorithms and their analysis
1 Chapter 2 Program Performance – Part 2. 2 Step Counts Instead of accounting for the time spent on chosen operations, the step-count method accounts.
Algorithmic Complexity: Complexity Analysis of Time Complexity Complexities Nate the Great.
Program Performance & Asymptotic Notations CSE, POSTECH.
CSC 201 Analysis and Design of Algorithms Lecture 03: Introduction to a CSC 201 Analysis and Design of Algorithms Lecture 03: Introduction to a lgorithms.
Week 2 CS 361: Advanced Data Structures and Algorithms
Data Structures and Algorithms Lecture 5 and 6 Instructor: Quratulain Date: 15 th and 18 th September, 2009 Faculty of Computer Science, IBA.
Algorithm Input Output An algorithm is a step-by-step procedure for solving a problem in a finite amount of time. Chapter 4. Algorithm Analysis (complexity)
1 Computer Algorithms Lecture 3 Asymptotic Notation Some of these slides are courtesy of D. Plaisted, UNC and M. Nicolescu, UNR.
Analysis of Algorithms
1 COMP3040 Tutorial 1 Analysis of algorithms. 2 Outline Motivation Analysis of algorithms Examples Practice questions.
Analysis of Algorithms These slides are a modified version of the slides used by Prof. Eltabakh in his offering of CS2223 in D term 2013.
Analyzing algorithms & Asymptotic Notation BIO/CS 471 – Algorithms for Bioinformatics.
Asymptotic Analysis-Ch. 3
Coursenotes CS3114: Data Structures and Algorithms Clifford A. Shaffer Department of Computer Science Virginia Tech Copyright ©
 DATA STRUCTURE DATA STRUCTURE  DATA STRUCTURE OPERATIONS DATA STRUCTURE OPERATIONS  BIG-O NOTATION BIG-O NOTATION  TYPES OF DATA STRUCTURE TYPES.
Algorithm Analysis (Algorithm Complexity). Correctness is Not Enough It isn’t sufficient that our algorithms perform the required tasks. We want them.
Asymptotic Notation (O, Ω, )
Program Efficiency & Complexity Analysis. Algorithm Review An algorithm is a definite procedure for solving a problem in finite number of steps Algorithm.
Algorithm Analysis CS 400/600 – Data Structures. Algorithm Analysis2 Abstract Data Types Abstract Data Type (ADT): a definition for a data type solely.
Chapter 5 Algorithms (2) Introduction to CS 1 st Semester, 2015 Sanghyun Park.
Algorithmic Analysis Charl du Plessis and Robert Ketteringham.
1 Asymptotic Notations Iterative Algorithms and their analysis Asymptotic Notations –Big O,  Notations Review of Discrete Math –Summations –Logarithms.
Time Complexity of Algorithms (Asymptotic Notations)
1 Algorithms  Algorithms are simply a list of steps required to solve some particular problem  They are designed as abstractions of processes carried.
Big-O. Algorithm Analysis Exact analysis: produce a function f(n) measuring how many basic steps are needed for a given inputs n On any input of size.
Analysis of Algorithm. Why Analysis? We need to know the “behavior” of algorithms – How much resource (time/space) does it use So that we know when to.
Algorithm Analysis Algorithm Analysis Lectures 3 & 4 Resources Data Structures & Algorithms Analysis in C++ (MAW): Chap. 2 Introduction to Algorithms (Cormen,
Asymptotic Notations By Er. Devdutt Baresary. Introduction In mathematics, computer science, and related fields, big O notation describes the limiting.
David Luebke 1 1/6/2016 CS 332: Algorithms Asymptotic Performance.
Algorithm Analysis (Big O)
Algorithm Complexity L. Grewe 1. Algorithm Efficiency There are often many approaches (algorithms) to solve a problem. How do we choose between them?
13 February 2016 Asymptotic Notation, Review of Functions & Summations.
1 Chapter 2 Algorithm Analysis All sections. 2 Complexity Analysis Measures efficiency (time and memory) of algorithms and programs –Can be used for the.
Computational complexity The same problem can frequently be solved with different algorithms which differ in efficiency. Computational complexity is a.
1 Chapter 2 Algorithm Analysis Reading: Chapter 2.
Analysis of Algorithms Spring 2016CS202 - Fundamentals of Computer Science II1.
GC 211:Data Structures Week 2: Algorithm Analysis Tools Slides are borrowed from Mr. Mohammad Alqahtani.
Data Structures & Algorithm CS-102 Lecture 12 Asymptotic Analysis Lecturer: Syeda Nazia Ashraf 1.
Algorithm Analysis 1.
Chapter 2 Algorithm Analysis
Analysis of Algorithms
Introduction to Algorithms
Big-O notation.
Time Complexity Analysis Neil Tang 01/19/2010
Algorithm Analysis Neil Tang 01/22/2008
Algorithm Analysis Lectures 3 & 4
Algorithm Analysis (not included in any exams!)
Analysys & Complexity of Algorithms
Chapter 2.
Asst. Dr.Surasak Mungsing
Presentation transcript:

CSE 3358 NOTE SET 2 Data Structures and Algorithms 1

Overview: 2  What are we measuring and why?  Computational complexity introduction  Big-O Notation

Problem 3  For a problem  Different ways to solve – differing algorithms  Problem: Searching an element in an array Possible searching algorithms? 

The Selection Problem 4  Problem: Find the Kth largest number in a set  Solution Possibilities: 

The Selection Problem 5  If dataset size = 10,000,000 and k = 5,000,000  Previous algos could take several days  Is one algorithm better than the other?  Are there better algorithms?

Efficiency 6  Limited amount of resources to use in solving a problem.  Resource Examples:  We can use any metric to compare various algorithms intended to solve the same problem.  Using some metrics in for some problems might not be enlightening…

Computational Complexity 7  Computational complexity – the amount of effort needed to apply an algorithm or how costly it is.  Two most common metrics (and the ones we’ll use)  Time (most common)  Space  Time to execute an algorithm on a particular data set is system dependent. Why?

Seconds? Microseconds? Nanoseconds? 8  Can’t use the above when talking about algorithms unless specific to a particular machine at a particular time.  Why not?

What will we use? 9  Logical units that express the relationship between the size n of a data set and the amount of time t required to process the data  For algorithm X using dataset n, T(n) = amount of time needed to execute X using n.  Problem: Ordering of the values in n can affect T(n). What to do?

How we measure resource usage 10  Three primary ways of mathematically discussing the amount of resources used by an algorithm  O(f(n))  Ω (f(n))   (f(n))  What is ___(f(n)) ? 

The Definitions 11  T(N) = O(f(n)) if there are positive constants c and n 0 such that T(N) = n 0.  T(N) = Ω (g(n)) if there are positive constants c and n 0 such that T(N) >= c*g(n) when N >= n 0.  T(N) =  (h(n)) iff T(N) = O(h(n)) and T(N) = Ω (h(n))

The Goal??? 12  To place a relative ordering on functions  To examine the relative rates of growth.  Example:

Big - Oh 13  T(N) = O(f(n))  What does this really mean?  Means:  T is big-O of f if there is a positive number c such that T is not larger than c*f for sufficiently large ns (for all ns larger than some number N)  In other words:  The relationship between T and f can be expressed by stating either that f(n) is an upper bound on the value of T(n) or that, in the long run, T grows at most as fast as f.

Asymptotic Notation: Big-O 14 Graphic Example

Asymptotic Notation: Big-Oh 15 Example: Show that 2n 2 + 3n + 1 is O(n 2 ). By the definition of Big-O 2n 2 + 3n + 1 = N. So we must find a c and N such that the inequality holds for all n > N. How?

Asymptotic Notation: Big-O 16  Reality Check:  We’re interested in what happens to the number of ops needed to solve a problem as the size of the input increases toward infinity.  Not too interested in what happens with small data sets.

Notes on Notation 17  Very common to see T(n) = O(f(n))  Not completely accurate  not symmetric about =  Technically, O(f(n)) is a set of functions.  Set definition O(g(n)) = { f(n): there are constants c > 0, N>0 such that 0 N.}  When we say f(n) = O(g(n)), we really mean that f(n) ∈ O(g(n)).

Asymptotic Notation: Big-O 18 Show that n 2 = O(n 3 ).

Three Cases for Analysis 19  Best Case Analysis:  when the number of steps needed to complete an algorithm with a data set is minimized  e.g. Sorting a sorted list  Worst Case Analysis:  when the maximum number of steps possible with an algorithm is needed to solve a problem for a particular data set  Average Case Analysis:

Example 20  The problem is SORTING (ascending)  Best Case:  Worst Case:  Average Case: Data Set: n = _______

T(N)? 21  For a particular algorithm, how do we determine T(N)?  Use a basic model of computation. Instructions are executed sequentially Standard simple instructions Add, subtract, multiply, divide Comparison, store, retrieve  Assumptions: Takes one time unit, T(1) to do anything simple

Determining Complexity  How can we determine the complexity of a particular algorithm? int sum(int* arr, int size) { int sum = 0; for (int i = 0; i < size; i++) sum += arr[i]; return sum; }

23 ?