lecture27 - Lecture 27 Counting Recap Recursive algorithms...

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

View Full Document Right Arrow Icon
Lecture 27 Counting
Background image of page 1

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

View Full DocumentRight Arrow Icon
Recap Recursive algorithms Correctness, running time analysis using induction May be inefficient
Background image of page 2
Fibonnaci(n) If n = 0, return 0 Else If n = 1, return 1 Else return Fibonacci(n-1) + Fibonacci(n-2)
Background image of page 3

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

View Full DocumentRight Arrow Icon
Basic Counting Principles The product rule Sum rule Inclusion-Exclusion |A| + |B| - |A B|
Background image of page 4
Example How many bit strings of length 8 either start with 1 or end with 00?
Background image of page 5

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

View Full DocumentRight Arrow Icon
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
Background image of page 6
Example How many bit strings of length 4 do not have two consecutive 1s?
Background image of page 7

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

View Full DocumentRight Arrow Icon
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
Background image of page 8
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
Background image of page 9

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

View Full DocumentRight Arrow Icon
Generalized pigeonhole principle If N objects are placed into k boxes, then there is at least one box containing N / k objects
Background image of page 10
Generalized pigeonhole principle Among 100 people, there are at least X people born in the same month. X = ? X =
Background image of page 11

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

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

This note was uploaded on 10/21/2011 for the course CSCI 2011 taught by Professor Staff during the Spring '08 term at Minnesota.

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 Right Arrow Icon
Ask a homework question - tutors are online