discrete mathematics summer 2006
Download
Skip this Video
Download Presentation
Discrete Mathematics Summer 2006

Loading in 2 Seconds...

play fullscreen
1 / 35

Discrete Mathematics Summer 2006 - PowerPoint PPT Presentation


  • 129 Views
  • Uploaded on

Discrete Mathematics Summer 2006. By Dan Barrish-Flood originally for Fundamental Algorithms For use by Harper Langston in D.M. What is an Algorithm?. A problem is a precise specification of input and desired output

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' Discrete Mathematics Summer 2006' - minna


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
discrete mathematics summer 2006

Discrete Mathematics Summer 2006

By Dan Barrish-Flood originally for Fundamental Algorithms

For use by Harper Langston in D.M.

what is an algorithm
What is an Algorithm?
  • A problem is a precise specification of input and desired output
  • An algorithm is a precise specification of a method for solving a problem.
what we want in an algorithm
What We Want in an Algorithm
  • Correctness
    • Always halts
    • Always gives the right answer
  • Efficiency
    • Time
    • Space
  • Simplicity
a typical problem
A Typical Problem

Sorting

  • Input:
    • A sequence b1, b2, ... bn
  • Output:
    • A permutation of that sequence b1, b2, ... bnsuch that
running time
Running Time

tJ is the number of times the “while” loop test in line 5 is executed for that value of j. Total running time is

c1 (n) + c2(n-1) +…+c8(n-1)

a better way to estimate running time
A Better Way to Estimate Running Time
  • Trying to determine the exact running time is tedious, complicated and platform-specific.
  • Instead, we’ll bound the worst-case running time to within a constant factor for large inputs.
  • Why worst-case?
    • It’s easier.
    • It’s a guarantee.
    • It’s well-defined.
    • Average case is often no better.
insertion sort redux
Insertion Sort, Redux
  • Outer loop happens about n times.
  • Inner loop is done j times for each j, worst case.
  • j is always < n
  • So running time is upper-bounded by about

“Insertion sort runs in q(n2) time, worst-case.”

slide9
We’ll make all the “about”s and “rough”s precise.
  • These so-called asymptotic running times dominate constant factors for large enough inputs.
functions
Functions
  • constants
  • polynomials
  • exponentials
  • logarithms and polylogarithms
  • factorial
slide12
f(n) is monotonically increasing iff

I.e. It never “goes down” — always increases or stays the same.

For strictly increasing, replace £ in the above with <.

I.e. The function is always going up.

slide13
Are constant functions monotonically increasing?

Yes! (But not strictly increasing.)

If , then is strictly increasing.

So even increases forever to

log facts
n = b log b n (definition)

logb(xy)=logbx + logby

logban= nlogba

logbx = logcx / logcb

logb(1/a) = -logba

logba = 1/(logab)

alogbc= clogba

if b > 1, then logbn is strictly increasing.

Log Facts
more about logs
More About Logs

A polylogarithm is just

bounding functions
Bounding Functions
  • We are more interested in finding upper and lower bounds on functions that describe the running times of algorithms, rather than finding the exact function.
  • Also, we are only interested in considering large inputs: everything is fast for small inputs.
  • So we want asymptotic bounds.
  • Finally, we are willing to neglect constant factors when bounding. They are tedious to compute, and are often hardware-dependent anyway.
big oh facts
Big-Oh Facts
  • The “=” is misleading. E.g
  • It denotes an upper bound, not necessarily a tight bound. Thus,

is meaningless.

  • Transitivity:
examples
Examples

We’ve seen that 3n + 8 = O(n).

Is 10n = O(3n + 8)?

Yes: choose c = 10, n0 = 1:

10n£ 30n+ 80

more examples
More Examples

2n2 + 5n - 8 = O(n2)?

Yes:

2n2 + 5n - 8 £ cn2

¸n2: 2 + 5/n - 8/n2£c

Choose c = 3; subtracting 2:

5/n - 8/n2£ 1

Choose no = 5

ad