Relations Over Asymptotic Notations. Overview of Previous Lecture Although Estimation but Useful It is not always possible to determine behaviour of an.

Slides:



Advertisements
Similar presentations
 The running time of an algorithm as input size approaches infinity is called the asymptotic running time  We study different notations for asymptotic.
Advertisements

CS344: Introduction to Artificial Intelligence Pushpak Bhattacharyya CSE Dept., IIT Bombay Lecture– 4, 5, 6: A* properties 9 th,10 th and 12 th January,
April 9, 2015Applied Discrete Mathematics Week 9: Relations 1 Solving Recurrence Relations Another Example: Give an explicit formula for the Fibonacci.
Discrete Structures & Algorithms Functions & Asymptotic Complexity.
Estimating Running Time Algorithm arrayMax executes 3n  1 primitive operations in the worst case Define a Time taken by the fastest primitive operation.
Complexity 15-1 Complexity Andrei Bulatov Hierarchy Theorem.
Complexity 13-1 Complexity Andrei Bulatov Hierarchy Theorem.
Chapter 3 Growth of Functions
Big-O and Friends. Formal definition of Big-O A function f(n) is O(g(n)) if there exist positive numbers c and N such that: f(n) = N Example: Let f(n)
Asymptotic Growth Rate
Cutler/HeadGrowth of Functions 1 Asymptotic Growth Rate.
CSE 421 Algorithms Richard Anderson Lecture 4. What does it mean for an algorithm to be efficient?
25 June 2015Comp 122, Spring 2004 Asymptotic Notation, Review of Functions & Summations.
Asymptotic Analysis Motivation Definitions Common complexity functions
Data Structures, Spring 2004 © L. Joskowicz 1 Data Structures – LECTURE 2 Elements of complexity analysis Performance and efficiency Motivation: analysis.
Tirgul 2 Asymptotic Analysis. Motivation: Suppose you want to evaluate two programs according to their run-time for inputs of size n. The first has run-time.
Data Structures and Algorithms1 Basics -- 2 From: Data Structures and Their Algorithms, by Harry R. Lewis and Larry Denenberg (Harvard University: Harper.
CPSC 411 Design and Analysis of Algorithms Andreas Klappenecker.
DATA STRUCTURES AND ALGORITHMS Lecture Notes 1 Prepared by İnanç TAHRALI.
CSE 373 Data Structures and Algorithms Lecture 4: Asymptotic Analysis II / Math Review.
Mathematics Review and Asymptotic Notation
CSC 201 Analysis and Design of Algorithms Lecture 04: CSC 201 Analysis and Design of Algorithms Lecture 04: Time complexity analysis in form of Big-Oh.
1 Computer Algorithms Lecture 3 Asymptotic Notation Some of these slides are courtesy of D. Plaisted, UNC and M. Nicolescu, UNR.
CS 3343: Analysis of Algorithms
CS 221 Analysis of Algorithms Instructor: Don McLaughlin.
Asymptotic Analysis-Ch. 3
Coursenotes CS3114: Data Structures and Algorithms Clifford A. Shaffer Department of Computer Science Virginia Tech Copyright ©
MCA 202: Discrete Structures Instructor Neelima Gupta
Algorithms Growth of Functions. Some Notation NNatural numbers RReal numbers N + Positive natural numbers R + Positive real numbers R * Non-negative real.
Analysis of Algorithms1 O-notation (upper bound) Asymptotic running times of algorithms are usually defined by functions whose domain are N={0, 1, 2, …}
CPSC 411 Design and Analysis of Algorithms
Measuring complexity Section 7.1 Giorgi Japaridze Theory of Computability.
Growth of Functions. 2 Analysis of Bubble Sort 3 Time Analysis – Best Case The array is already sorted – no swap operations are required.
Time Complexity of Algorithms (Asymptotic Notations)
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.
Chapter 2 Computational Complexity. Computational Complexity Compares growth of two functions Independent of constant multipliers and lower-order effects.
Discrete Mathematics Lecture # 15 Types of Relations (contd.)
COP 3530 Spring2012 Data Structures & Algorithms Discussion Session Week 5.
Asymptotics and Recurrence Equations Prepared by John Reif, Ph.D. Analysis of Algorithms.
David Meredith Growth of Functions David Meredith
CSE 373: Data Structures and Algorithms Lecture 4: Math Review/Asymptotic Analysis II 1.
13 February 2016 Asymptotic Notation, Review of Functions & Summations.
Asymptotic Notation Faculty Name: Ruhi Fatima
CS344: Introduction to Artificial Intelligence Pushpak Bhattacharyya CSE Dept., IIT Bombay Lecture 17– Theorems in A* (admissibility, Better performance.
CSE 421 Algorithms Richard Anderson Winter 2009 Lecture 4.
CS621: Artificial Intelligence Pushpak Bhattacharyya CSE Dept., IIT Bombay Lectures 18, 19, 20– A* Monotonicity 2 nd, 6 th and 7 th September, 2010.
Algorithms Lecture #05 Uzair Ishtiaq. Asymptotic Notation.
Computational complexity The same problem can frequently be solved with different algorithms which differ in efficiency. Computational complexity is a.
DR. Gatot F. Hertono, MSc. Design and Analysis of ALGORITHM (Session 2)
Complexity of Algorithms Fundamental Data Structures and Algorithms Ananda Guna January 13, 2005.
Advanced Algorithms Analysis and Design
CSE 3358 NOTE SET 2 Data Structures and Algorithms 1.
Analysis of Algorithms CS 477/677 Instructor: Monica Nicolescu Lecture 2.
Asymptotic Complexity
Chapter 3 Growth of Functions Lee, Hsiu-Hui
Reflexivity, Symmetry, and Transitivity
Assignment 2 Tze calculations.
Time Complexity Analysis Neil Tang 01/19/2010
Algorithm Analysis Neil Tang 01/22/2008
O-notation (upper bound)
Asymptotic Growth Rate
CS 3343: Analysis of Algorithms
Orders of Growth Rosen 5th ed., §2.2.
Advanced Analysis of Algorithms
Advanced Algorithms Analysis and Design
Advanced Analysis of Algorithms
Big Omega, Theta Defn: T(N) = (g(N)) if there are positive constants c and n0 such that T(N)  c g(N) for all N  n0 . Lingo: “T(N) grows no slower than.
THE WELL ORDERING PROPERTY
An Upper Bound g(n) is an upper bound on f(n). C++ Review EECE 352.
Presentation transcript:

Relations Over Asymptotic Notations

Overview of Previous Lecture Although Estimation but Useful It is not always possible to determine behaviour of an algorithm using Θ-notation. For example, given a problem with n inputs, we may have an algorithm to solve it in a.n 2 time when n is even and c.n time when n is odd. OR We may prove that an algorithm never uses more than e.n 2 time and never less than f.n time. In either case we can neither claim  (n) nor  (n 2 ) to be the order of the time usage of the algorithm. Big O and  notation will allow us to give at least partial information Mashhood's Web Family mashhoood.webs.com 2

Definition: Let X be a non-empty set and R is a relation over X then R is said to be reflexive if (a, a)  R,  a  X, Example 1: Let G be a graph. Let us define a relation R over G as if node x is connected to y then (x, y)  G. Reflexivity is satisfied over G if for every node there is a self loop. Reflexive Relation Mashhood's Web Family mashhoood.webs.com 3

Example 1 Since, 0  f(n)  cf(n)  n  n 0 = 1,if c = 1 Hence f(n) = O(f(n)) Example 2 Since, 0  cf(n)  f(n)  n  n 0 = 1, if c = 1 Hence f(n) =  (f(n)) Example 3 Since, 0  c 1 f(n)  f(n)  c 2 f(n)  n  n 0 = 1,if c 1 = c 2 = 1 Hence f(n) =  (f(n)) Note: All the relations, , , O, are reflexive Reflexivity Relations over , , O Mashhood's Web Family mashhoood.webs.com 4

Example As we can not prove that f(n) 0 Therefore 1. f(n)  o(f(n)) and 2.f(n)   (f(n)) Note : Hence small o and small omega are not reflexive relations Little o and  are not Reflexivity Relations Mashhood's Web Family mashhoood.webs.com 5

Definition: Let X be a non-empty set and R is a relation over X then R is said to be symmetric if  a, b  X, (a, b)  R  (b, a)  R Example 1: Let P be a set of all persons, and B be a relation over P such that if (x, y)  B then x is brother of y. This relation is not symmetric because (Anwer, Sadia)  B  (Saida, Brother)  B Symmetry Mashhood's Web Family mashhoood.webs.com 6

Property : prove that f(n) =  (g(n))  g(n) =  (f(n)) Proof Since f(n) =  (g(n)) i.e. f(n)   (g(n))   constants c 1, c 2 > 0 and n 0  N such that 0  c 1 g(n)  f(n)  c 2 g(n)  n  n 0 (1) (1)  0  c 1 g(n)  f(n)  c 2 g(n)  0  f(n)  c 2 g(n)  0  (1/c 2 )f(n)  g(n)(2) (1)  0  c 1 g(n)  f(n)  c 2 g(n)  0  c 1 g(n)  f(n)  0  g(n)  (1/c 1 )f(n)(3) Symmetry over  Mashhood's Web Family mashhoood.webs.com 7

From (2),(3): 0  (1/c 2 )f(n)  g(n)  0  g(n)  (1/c 1 )f(n)  0  (1/c 2 )f(n)  g(n)  (1/c 1 )f(n) Suppose that 1/c 2 = c 3, and 1/c 1 = c 4, Now the above equation implies that 0  c 3 f(n)  g(n)  c 4 f(n),  n  n 0  g(n) =  (f(n)),  n  n 0 Hence it proves that, f(n) =  (g(n))  g(n) =  (f(n)) Symmetry over  Mashhood's Web Family mashhoood.webs.com 8

Definition: Let X be a non-empty set and R is a relation over X then R is said to be transitive if  a, b, c  X, (a, b)  R  (b, c)  R  (a, c)  R Example 1: Let P be a set of all persons, and B be a relation over P such that if (x, y)  B then x is brother of y. This relation is transitive this is because (x, y)  B  (y, z)  B  (x, z)  B Example 2: Let P be a set of all persons, and F be a relation over P such that if (x, y)  F then x is father of y. Of course this relation is not a transitive because if (x, y)  F  (y, z)  F  (x, z)  F Transitivity Mashhood's Web Family mashhoood.webs.com 9

Prove the following 1.f(n) =  (g(n)) & g(n) =  (h(n))  f(n) =  (h(n)) 2.f(n) = O(g(n)) & g(n) = O(h(n))  f(n) = O(h(n)) 3.f(n) =  (g(n)) & g(n) =  (h(n))  f(n) =  (h(n)) 4.f(n) = o (g(n)) & g(n) = o (h(n))  f(n) = o (h(n)) 5.f(n) =  (g(n)) & g(n) =  (h(n))  f(n) =  (h(n)) Note It is to be noted that all these algorithms complexity measuring notations are in fact relations which satisfy the transitive property. Transitivity Relation over , , O, o and  Mashhood's Web Family mashhoood.webs.com 10

Property 1 f(n) =  (g(n)) & g(n) =  (h(n))  f(n) =  (h(n)) Proof Since f(n) =  (g(n)) i.e. f(n)   (g(n))   constants c 1, c 2 > 0 and n 01  N such that 0  c 1 g(n)  f(n)  c 2 g(n)  n  n 01 (1) 2.Now since g(n) =  (h(n)) i.e. g(n)   (h(n))   constants c 3, c 4 > 0 and n 02  N such that 0  c 3 h(n)  g(n)  c 4 h(n)  n  n 02 (2) 3.Now let us suppose that n 0 = max (n 01, n 02 ) Transitivity Relation over  Mashhood's Web Family mashhoood.webs.com 11

4.Now we have to show that f(n) =  (h(n)) i.e. we have to prove that  constants c 5, c 6 > 0 and n 0  N such that 0  c 5 h(n)  f(n)  c 6 h(n)? (2)  0  c 3 h(n)  g(n)  c 4 h(n)  0  c 3 h(n)  g(n)(3) (1)  0  c 1 g(n)  f(n)  c 2 g(n)  0  c 1 g(n)  f(n)  0  g(n)  (1/c 1 )f(n)(4) From (3) and (4),0  c 3 h(n)  g(n)  (1/c 1 )f(n)  0  c 1 c 3 h(n)  f(n) (5) Transitivity Relation over  Mashhood's Web Family mashhoood.webs.com 12

(1)  0  c 1 g(n)  f(n)  c 2 g(n)  0  f(n)  c 2 g(n)  0  (1/c 2 )f(n)  g(n)(6) (2)  0  c 3 h(n)  g(n)  c 4 h(n)  0  g(n)  c 4 h(n)(7) From (6) and (7),0  (1/c 2 )f(n)  g(n)  (c 4 )h(n)  0  (1/c 2 )f(n)  (c 4 )h(n)  0  f(n)  c 2 c 4 h(n) (8) From (5), (8), 0  c 1 c 3 h(n)  f(n)  0  f(n)  c 2 c 4 h(n) 0  c 1 c 3 h(n)  f(n)  c 2 c 4 h(n) 0  c 5 h(n)  f(n)  c 6 h(n) And hence f(n) =  (h(n))  n  n 0 Transitivity Relation over  Mashhood's Web Family mashhoood.webs.com 13

Property 2 f(n) = O(g(n)) & g(n) = O(h(n))  f(n) = O(h(n)) Proof Since f(n) = O(g(n)) i.e. f(n)  O(g(n))   constants c 1 > 0 and n 01  N such that 0  f(n)  c 1 g(n)  n  n 01 (1) 2.Now since g(n) = O(h(n)) i.e. g(n)  O(h(n))   constants c 2 > 0 and n 02  N such that 0  g(n)  c 2 h(n)  n  n 02 (2) 3.Now let us suppose that n 0 = max (n 01, n 02 ) Transitivity Relation over Big O Mashhood's Web Family mashhoood.webs.com 14

Now we have to two equations 0  f(n)  c 1 g(n)  n  n 01 (1) 0  g(n)  c 2 h(n)  n  n 02 (2) (2)  0  c 1 g(n)  c 1 c 2 h(n)  n  n 02 (3) From (1) and (3) 0  f(n)  c 1 g(n)  c 1 c 2 h(n) Now suppose that c 3 = c 1 c 2 0  f(n)  c 1 c 2 h(n) And hence f(n) = O(h(n))  n  n 0 Transitivity Relation over Big O Mashhood's Web Family mashhoood.webs.com 15

Assignment Prove that 1.f(n) =  (g(n)) & g(n) =  (h(n))  f(n) =  (h(n)) 2.f(n) = o (g(n)) & g(n) = o (h(n))  f(n) = o (h(n)) 3.f(n) =  (g(n)) & g(n) =  (h(n))  f(n) =  (h(n)) To be submitted within the first lecture after Mid Term Mashhood's Web Family mashhoood.webs.com 16