lecture27

# lecture27 - Lecture 27 Counting Recap Recursive algorithms...

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

Lecture 27 Counting

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

View Full Document
Recap Recursive algorithms Correctness, running time analysis using induction May be inefficient
Fibonnaci(n) If n = 0, return 0 Else If n = 1, return 1 Else return Fibonacci(n-1) + Fibonacci(n-2)

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

View Full Document
Basic Counting Principles The product rule Sum rule Inclusion-Exclusion |A| + |B| - |A B|
Example How many bit strings of length 8 either start with 1 or end with 00?

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

View Full Document
Tree diagrams A systematic way of counting exhaustively Starting from the root, branch at every choice: count the number of leaves Generalizes the product rule
Example How many bit strings of length 4 do not have two consecutive 1s?

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

View Full Document
Pigeonhole principle If k +1 or more objects (pigeons) are placed into k boxes, then there is at least one box containing two or more of the objects
Pigeonhole principle examples In a group of 367 people, there must be two people with the same birthday As there are 366 possible birthdays In a set of 27 English words, at least two words must start with the same letter As there are only 26 letters

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

View Full Document
Generalized pigeonhole principle If N objects are placed into k boxes, then there is at least one box containing N / k objects
Generalized pigeonhole principle Among 100 people, there are at least X people born in the same month. X = ? X =

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 / 29

lecture27 - Lecture 27 Counting Recap Recursive algorithms...

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

View Full Document
Ask a homework question - tutors are online