CSE 502N - PowerPoint PPT Presentation

1 / 13
About This Presentation
Title:

CSE 502N

Description:

Divide & Conquer as a design strategy. Running-Time Functions ... Divide & Conquer. T3(n) = c n log(n) ... Conquer the subproblems by solving them recursively. ... – PowerPoint PPT presentation

Number of Views:27
Avg rating:3.0/5.0
Slides: 14
Provided by: richards89
Category:

less

Transcript and Presenter's Notes

Title: CSE 502N


1
CSE 502N
  • May 25, 2006

2
Last Time
  • Fast Algorithms Good
  • Faster Algorithms Better
  • Closest-Pair of Points Problem
  • Naïve Algorithm (1 2)
  • Divide Conquer Algorithm
  • Crude Running-Time Calculations

3
Today
  • Growth-Rate Analysis
  • as a function of input size
  • Designing Algorithms
  • Divide Conquer as a design strategy

4
Running-Time Functions
  • Running-time for closest-pair algorithms
  • Naïve 1
  • T1(n) 11n2 - 8n 2
  • Naïve 2
  • T2(n) 5n2 - 4n 2
  • Divide Conquer
  • T3(n) cnlog(n), for some constant c
  • We might say that T1(n) and T2(n) are about the
    same, and T3(n) is much faster. Why?

5
Growth of Functions
  • Design elegant, scalable algorithms
  • Want to know how running time increases w.r.t. n
    as n increases without bound
  • Termed Asymptotic efficiency
  • We use asymptotic notation

6
O-notation (Upper Bound)
  • For non-negative functions, f(n) and g(n) if
    there exists
  • integer n0
  • constant c gt 0
  • where for all integers n gt n0, f(n)  cg(n), then
    f(n)  O(g(n))
  • Can be read f(n) is Big Oh of g(n)

7
?-notation (Lower Bound)
  • For non-negative functions, f(n) and g(n) if
    there exists
  • integer n0
  • constant c gt 0
  • where for all integers n gt n0, f(n) cg(n), then
    f(n)  ?(g(n))
  • Can be read f(n) is Big Omega of g(n)

8
?-notation (Tight Bound)
  • If f(n) O(g(n)) and f(n) ?(g(n)), we say f(n)
    ?(g(n))
  • We can say
  • f(n) is Theta g(n)
  • f(n) is order g(n)

9
Ratio Test
  • Given two function, f(n) and g(n)
  • Calculate limit of f(n) / g(n) as n ? infinity
  • infinity f(n) ?(g(n))
  • zero f(n) O(g(n))
  • constant f(n) ?(g(n))
  • Compare T(n) for brute force algorithms and
    divide and conquer.

10
Example Sorting
  • InputSequence of n numbers lta1, a2, , angt
  • Output Permutation (re-ordering) lta1, a2, ,
    angt of the input sequence such that a1 ? a2 ?
    ? an
  • We call the numbers to be sorted keys

11
Propose Simple Sorting Algorithm
  • Consider manually sorting a deck of cards
  • How fast is our algorithm?
  • Does our algorithm depend on something other than
    the size of our input?
  • Can we do better?

12
Divide Conquer Approach
  • Many useful algorithms are recursive
  • 3 Steps
  • Divide the problem into similar, smaller
    subproblems
  • Conquer the subproblems by solving them
    recursively. (If the subproblems are small
    enough, solve them directly)
  • Combine the subproblem solutions into a global
    solution

13
Propose DC Sorting Algorithm
  • Similar to FastClosestPair algorithm
  • Does card deck sorting analogy still apply?
  • How fast is our algorithm?
  • Does it depend on something other than the size
    of our input?
Write a Comment
User Comments (0)
About PowerShow.com