notes04 - CSE 2320 Notes 4: Recurrences (Last updated...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
CSE 2320 Notes 4: Recurrences (Last updated 3/26/12 13:58 A3/P3) Sedgewick 2.5 4.A. B OUNDING R ECURRENCES A SYMPTOTICALLY Goal: Take a function T n ( ) that is defined recursively and find f n ( ) such that T n ( ) Î Q f n ( ) ( ). Need to establish both T n ( ) Î O f n ( ) ( ) and T n ( ) Î W f n ( ) ( ) (without using the limit theorems). 4.B. R ECURRENCES , C ONSTANTS , AND E VALUATING BY B RUTE E XPANSION Consider the recurrence: T n ( ) = T n 2 ae è ç ö ø ÷ + e = T n 2 ae è ç ö ø ÷ + Q 1 ( ) T 1 ( ) = d = Q 1 ( ) Suppose n = 2 k : T 1 ( ) = d T 2 ( ) = T 1 ( ) + e = d + e T 4 ( ) = T 2 ( ) + e = d + e ( ) + e = d + 2 e T 8 ( ) = T 4 ( ) + e = d + 2 e ( ) + e = d + 3 e T 2 k ae è ç ö ø ÷ = T 2 k -1 ae è ç ö ø ÷ + e = d + ke = d + e lg n = Q log n ( ) Consider the recurrence: T n ( ) = 2 T n 2 ae è ç ö ø ÷ + en = 2 T n 2 ae è ç ö ø ÷ + Q n ( ) T 1 ( ) = d = Q 1 ( )
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Suppose n = 2 k : T 1 ( ) = d T 2 ( ) = 2 T 1 ( ) + 2 e = 2 d + 2 e T 4 ( ) = 2 T 2 ( ) + 4 e = 2 2 d + 2 e ( ) + 4 e = 4 d + 8 e T 8 ( ) = 2 T 4 ( ) + 8 e = 2 4 d + 8 e ( ) + 8 e = 8 d + 24 e T 16 ( ) = 2 T 8 ( ) +16 e = 2 8 d + 24 e ( ) +16 e =16 d + 64 e T n = 2 k ae è ç ö ø ÷ = 2 T 2 k -1 ae è ç ö ø ÷ + 2 k e = 2 2 k -1 d + 2 k -1 k - 1 ( ) e ae è ç ö ø ÷ + 2 k e = 2 k d + 2 k ke = nd + en lg n = Q n log n ( ) (see notes04.c for this and other examples of expansion) Constants d and e do not usually matter . . . 4.C. T HE S UBSTITUTION M ETHOD FOR B OUNDING R ECURRENCES Method Guess bound (lower and/or upper Ο ) [On exams the guess will be given to you] Verify by math induction (solve for constants for some function in asymptotic set) i) Assume bounding hypothesis works for k < n ii) Show bounding hypothesis works for n in exactly the same form as (i). Refine bound Example: Binary search recurrence (number of probes) T n ( ) = T n 2 ae è ç ö ø ÷ +1 Ο log n ( ) Assume T k ( ) £ c lg k for k < n . (Note : log a n Î Q log b n ( ) ) T n 2 ae è ç ö ø ÷ £ c lg n 2 ae è ç ö ø ÷ = c lg n - lg2 ( ) = c lg n - c T n ( ) = T n 2 ae è ç ö ø ÷ +1 £ c lg n - c +1 £ c lg n if c ³ 1 2
Background image of page 2
log n ( ) Assume T k ( ) ³ c lg k for k < n T n 2 ae è ç ö ø ÷ ³ c lg n 2 ae è ç ö ø ÷ = c lg n - lg2 ( ) = c lg n - c T n ( ) = T n 2 ae è ç ö ø ÷ +1 ³ c lg n - c +1 ³
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/25/2012 for the course CSE 2320 taught by Professor Bobweems during the Spring '12 term at UT Arlington.

Page1 / 13

notes04 - CSE 2320 Notes 4: Recurrences (Last updated...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online