Asymptotic Concepts - PowerPoint PPT Presentation

1 / 35
About This Presentation
Title:

Asymptotic Concepts

Description:

Math Background: Review & Beyond. Asymptotic concepts & useful math ... lg n = log2 n ln n = loge n log n = log10 n. logk n = (log n)k. log log n = log (log n) ... – PowerPoint PPT presentation

Number of Views:37
Avg rating:3.0/5.0
Slides: 36
Provided by: johngr7
Category:

less

Transcript and Presenter's Notes

Title: Asymptotic Concepts


1
COMP 482 / ELEC 420
  • Asymptotic Concepts Useful Math

2
Math Background Review Beyond
  • Asymptotic concepts useful math
  • Recurrences
  • Probabilistic analysis

3
Your To-Do List
  • Read CLRS 3.1,A,B,3.2.
  • Assignment 1.

4
Defining Resource Usage
  • Time
  • Total time to elapsed program time
  • Space
  • Maximum space required during program execution
  • Processors
  • Number of processors used by parallel program

5
Defining Resource Usage
How does the running time depend on the
input? T(x) running time for instance x
Problem Impractical to use, e.g., 15 steps
to sort 3 9 1 7, 13 steps to sort 1 2 0 3 9,
Need to abstract away from the individual
instances.
6
Abstracting Resource Usage
  • Abstract based on size of input

How does the running time depend on the
input? T(n) running time for instances of size n
7
Abstracting Resource Usage
  • Whats confusing about this notation?

Worst case T(n) maxT(x) x is an instance of
size n Best case T(n) minT(x) x is an
instance of size n Average case T(n) ?xn
Prx ? T(x)
Two different kinds of functions T(instance)
T(size of instance) Wont use T(instance)
notation again, so can ignore.
8
Asymptotes Why?
  • Problem T(n) 3n2 14n 17
  • Too much detail constant factors may reflect
    implementation details lower terms are
    insignificant.

Solution Ignore constant factors low-order
terms.(Omitted details still important
pragmatically.)
3n2 gt 14n17 ? large enough n
9
Upper Bounds
  • Creating an algorithm proves we can solve the
    problem within a given bound.
  • But another algorithm might be faster.

E.g., sorting an array. Insertion sort ? O(n2)
10
Lower Bounds
  • Sometimes can prove that we cannot compute
    something without a sufficient amount of time.
  • That doesn't necessarily mean we know how to
    compute it in this lower bound.

E.g., sorting an array. comparisons needed in
worst case ? ?(n log n) Will prove this soon
11
Upper Lower Bounds Informal Summary
  • Upper bounds
  • ? O() lt o()
  • Lower bounds
  • ? ?() gt ?()
  • Upper lower (tight) bounds
  • ?()

12
Definitions O, ?
13
Examples O, ?
2n13 ? O( ? )
O(n)
Also, O(n2), O(5n), Can always weaken the
bound.
2n13 ? ?( ? )
?(n), also ?(log n), ?(1),
2n ? O(n) ? ?(n) ?
Given a c, 2n ? c?n, for all but small n. ?(n),
not O(n).
nlog n ? O(n5) ?
No. Given a c, log n ? c?5, for all large enough
n. Thus, ?(n5).
-n ? O(n) ?
No. -n not asymptotically positive.
14
Definitions o, ?
  • Might know that our upper lower bounds arent
    tight.
  • T(n) ? o(g(n))
  • ?
  • ? constants cgt0, ? constant n0gt0,such that
  • ? n?n0, 0 ? T(n) lt c?g(n)
  • T(n) ? ?(g(n))
  • ?
  • ? constants cgt0, ? constant n0gt0,such that
  • ? n?n0, T(n) gt c?g(n) ? 0

15
Examples o, ?
2n13 ? o(n) ? ?(n) ?
No to both! 2n13 lt c?n fails for many c. 2n13 gt
c?n fails for many c.
2n13 ? o( ? ) ?( ? )
o(n log n), o(n2), ?(log n), ?(1),
1 / log n ? o(1) ?
16
Definitions ?
  • T(n) ? ?(g(n))
  • ?
  • T(n) ? O(g(n)) and T(n) ? ?(g(n))
  • Ideally, find algorithms that are asymptotically
    as good as possible.

17
Alternate Definitions
Some authors use
  • T(n) ? O1(g(n))
  • ?
  • ? constants c,n0 gt 0
  • such that
  • ? n?n0, T(n) ? c?g(n)

What is an example of when O() and O1() disagree?
18
Notation
  • O(), ?(), are sets of functions.
  • But common to abuse notation

19
Review (mostly) some math useful for asymptotics
20
Bounds
  • Some useful algebra altb, cltd implies
  • -b lt -a
  • 1/b lt 1/a Unless a,b have different signs!
  • ac lt bc
  • ac lt bc If cgt0
  • ac lt bd But not necessarily a-c lt b-d or a-c
    gt b-d !
  • an lt bn If a,bgt0

21
Floor Ceilings
n objects in m groups ? some group has ?n/m?
objects
22
Logarithm Notation
  • lg n log2 n ln n loge n log n log10 n
  • logk n (log n)k
  • log log n log (log n)
  • log n k (log n) k
  • log nk log (nk)
  • log(0) n n log(i1) n log log(i) n
  • log n mini?0 log(i) n ? 1
  • How many times can you take the logarithm before
    its ? 1?

23
Exponentials Logarithms
cb
24
Factorials
  • Factorial vs. exponential
  • Bigger than some n! ?(2n)
  • Smaller than some n! o(nn)
  • log n! ?(n log n)

25
Choice Function
n choose k of k-combinations of an n-set
1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 5 10 10 5 1
There are many useful identities, but most are
easily derived from defn.
26
Summations
  • Find closed forms of summations.
  • A quick review of some techniques

27
Summations
Know some common ones
28
Summations
Know some common ones
29
Summations
Combine known summations with differentiation,
e.g.,
30
Summations
Bounding is often sufficient, e.g.,
31
Summations
Bounding is often sufficient.
  • Similar ideas
  • Rounding up with ? ?
  • Rounding up to a multiple of k
  • Rounding up to a power of k
  • Rounding down for ?()

32
Summations
Bounding is often sufficient, e.g.,
33
Summations
? What is the base case? ?
34
Summations
35
Summations
Bound/approximate by integrals, e.g.,
Write a Comment
User Comments (0)
About PowerShow.com