Download presentation
Presentation is loading. Please wait.
Published byAllen Jacobs Modified over 5 years ago
1
Algorithms CSCI 235, Spring 2019 Lecture 8 Recurrences III
2
Other examples T(n) = T(n/2) + n T(n) = 2T(n/2) + n2
3. T(n) = T(n/3) + T(2n/3) + n
3
Practice with recurrences
Example 1: T(n) = T(n/2) + n We will draw the tree in class
4
Solving example 1 Cost of level k = ? T(n) = ? A lower bound:
An upper bound: T(n) = ?
5
Example 2 Another equation: T(n) = 2T(n/2) + n2
We will draw this tree in class
6
Solution for example 2 Cost of level k = ? T(n) = ? Lower bound:
Upper bound: T(n) = ?
7
Example 3 Practice equation 3: T(n) = T(n/3) + T(2n/3) + n
We will draw this tree in class
8
Solving Recursion tree for example 3
Number of levels = ? Cost of each level = ? Total cost if tree is full = ? Some paths will be shorter, so cost will be less. Total cost is at most? T(n) = ?
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.