{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

L12_SolutionsRecurrences_b

# L12_SolutionsRecurrences_b - COMP170 Discrete Mathematical...

This preview shows pages 1–20. Sign up to view the full content.

1-1 COMP170 Discrete Mathematical Tools for Computer Science Discrete Math for Computer Science K. Bogart, C. Stein and R.L. Drysdale Section 4.3, pp. 157-167 Solutions to Recurrences Version 2b.2: Last updated, November 1, 2007 Slides c 2005 by M. J. Golin and G. Trippen Version without recursion trees

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

View Full Document
2-1 Growth Rates of Solutions to Recurrences Divide and Conquer Algorithms Three Different Behaviors Iterating Recurrences
3-1 Divide and Conquer Algorithms

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

View Full Document
3-2 Divide and Conquer Algorithms In the previous section we analyzed recurrences of the form T ( n ) = a if n = b c · T ( n - 1) + d if n > b
3-3 Divide and Conquer Algorithms In the previous section we analyzed recurrences of the form T ( n ) = a if n = b c · T ( n - 1) + d if n > b These corresponded to the analyses of recursive algorithms in which a problem of size n is solved by recursively solving a problem(s) of size n - 1 . We will now look at recurrences that arise from recursive algorithms in which problems of size n are solved by recursively solving problems of size n/m , for some fixed m . These recurrences will be in the form

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

View Full Document
3-4 Divide and Conquer Algorithms In the previous section we analyzed recurrences of the form T ( n ) = a if n = b c · T ( n - 1) + d if n > b These corresponded to the analyses of recursive algorithms in which a problem of size n is solved by recursively solving a problem(s) of size n - 1 . We will now look at recurrences that arise from recursive algorithms in which problems of size n are solved by recursively solving problems of size n/m , for some fixed m . These recurrences will be in the form T ( n ) = something given if n b c · T ( n/m ) + d if n > b
4-1 Divide and Conquer Algorithms Our first example will be binary search . Someone has chosen a number x between 1 and n . We need to discover x . We are only allowed to ask two types of questions:

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

View Full Document
4-2 Divide and Conquer Algorithms Our first example will be binary search . Someone has chosen a number x between 1 and n . We need to discover x . We are only allowed to ask two types of questions: Is x greater than k ? Is x equal to k ?
4-3 Divide and Conquer Algorithms Our first example will be binary search . Someone has chosen a number x between 1 and n . We need to discover x . We are only allowed to ask two types of questions: Is x greater than k ? Is x equal to k ? Our strategy will be to always ask greater than questions, at each step halving our search range, until the range only contains one number, when we ask a final equal to question

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

View Full Document
5-1 Binary Search Example
5-2 32 48 1 64 Binary Search Example

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

View Full Document
5-3 32 48 1 64 Binary Search Example Is x > 32 ?
5-4 32 48 1 64 Binary Search Example Is x > 32 ? Answer: Yes

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

View Full Document
5-5 32 48 1 64 Binary Search Example Is x > 32 ? Answer: Yes Is x > 48 ?
5-6 32 48 1 64 Binary Search Example Is x > 32 ? Answer: Yes Is x > 48 ? Answer: No

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

View Full Document
5-7 32 48 1 64 Binary Search Example Is x > 32 ? Answer: Yes Is x > 48 ? Answer: No Is x > 40 ?
5-8 32 48 1 64 Binary Search Example Is x > 32 ? Answer: Yes Is x > 48 ? Answer: No Is x > 40 ? Answer: No

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

View Full Document
5-9 32 48 1 64 Binary Search Example Is x > 32 ? Answer: Yes Is x > 48 ? Answer: No Is x > 40 ? Answer: No Is x > 36 ?
5-10 32 48 1 64 Binary Search Example Is x > 32 ? Answer: Yes Is x > 48 ? Answer: No Is x > 40 ? Answer: No Is x > 36 ? Answer: No

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 142

L12_SolutionsRecurrences_b - COMP170 Discrete Mathematical...

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

View Full Document
Ask a homework question - tutors are online