DOC PREVIEW
CMU CS 15251 - lecture

This preview shows page 1-2-3-4-5-6-7-8-55-56-57-58-59-60-61-62-112-113-114-115-116-117-118-119 out of 119 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 119 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 119 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 119 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 119 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 119 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 119 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 119 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 119 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 119 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 119 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 119 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 119 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 119 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 119 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 119 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 119 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 119 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 119 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 119 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 119 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 119 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 119 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 119 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 119 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 119 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

15-251Great Theoretical Ideas in Computer Science++()+( ) = ?Counting II: Recurring Problems and CorrespondencesLecture 7, September 16, 20082Review from last time...3AB1-1 onto Correspondence(just “correspondence” for short)4If a finite set A has a k-to-1 correspondence to finite set B, then |B| = |A|/k5Sometimes it is easiest to count the number of objects with property Q, by counting the number of objects that do not have property Q.6The number of subsets of an n-element set is 2n.7The number of subsets of size r that can be formed from an n-element set is:n!r!(n-r)!=nr8A choice tree provides a “choice tree representation” of a set S, if1. Each leaf label is in S, and each element of S is some leaf label2. No two leaf labels are the same9Product Rule (Rephrased)Suppose every object of a set S can be constructed by a sequence of choices with P1 possibilities for the first choice, P2 for the second, and so on. IF 1. Each sequence of choices constructs an object of type S2. No two different sequences create thesame objectThere are P1P2P3…Pn objects of type SANDTHEN10How Many Different Orderings of Deck With 52 Cards?What object are we making? Ordering of a deckConstruct an ordering of a deck by a sequence of 52 choices: 52 possible choices for the first card; 51 possible choices for the second card; : : 1 possible choice for the 52nd card.By product rule: 52 × 51 × 50 × … × 2 × 1 = 52!11The Sleuth’s CriterionThere should be a unique way to createan object in S.In other words:For any object in S, it should be possible to reconstruct the (unique) sequence of choices which lead to it.12The three big mistakes people make in associating a choice tree with a set S are:1. Creating objects not in S2. Leaving out some objects from the set S3. Creating the same object two different ways13DEFENSIVE THINKINGask yourself:Am I creating objects of the right type?Can I reverse engineer my choice sequence from any given object?14Inclusion-ExclusionIf A and B are two finite sets, what is the size of (A ∪ B) ?15Inclusion-ExclusionIf A and B are two finite sets, what is the size of (A ∪ B) ?|A| + |B| - |A ∩ B|15Inclusion-ExclusionIf A, B, C are three finite sets, what is the size of (A ∪ B ∪ C) ?16Inclusion-ExclusionIf A, B, C are three finite sets, what is the size of (A ∪ B ∪ C) ?|A| + |B| + |C| - |A ∩ B| - |A ∩ C| - |B ∩ C| + |A ∩ B ∩ C|16Inclusion-ExclusionIf A1, A2, …, An are n finite sets, what is the size of (A1 ∪ A2 ∪ … ∪ An) ?17Inclusion-ExclusionIf A1, A2, …, An are n finite sets, what is the size of (A1 ∪ A2 ∪ … ∪ An) ?∑i |Ai| - ∑i < j |Ai ∩ Aj| + ∑i < j < k |Ai ∩ Aj ∩ Ak| … + (-1)n-1 |A1 ∩ A2 ∩ … ∩ An|17Let’s use our principles to extend our reasoning to different types of objects18Counting Poker Hands1952 Card Deck, 5 card hands4 possible suits:♥♦♣♠13 possible ranks:2,3,4,5,6,7,8,9,10,J,Q,K,A2052 Card Deck, 5 card hands4 possible suits:♥♦♣♠13 possible ranks:2,3,4,5,6,7,8,9,10,J,Q,K,APair: set of two cards of the same rankStraight: 5 cards of consecutive rankFlush: set of 5 cards with the same suit20Ranked Poker HandsStraight Flush: a straight and a flush4 of a kind: 4 cards of the same rankFull House: 3 of one kind and 2 of anotherFlush: a flush, but not a straightStraight: a straight, but not a flush3 of a kind:3 of the same rank, but not a full house or 4 of a kind2 Pair: 2 pairs, but not 4 of a kind or a full houseA Pair21Straight Flush22Straight Flush9 choices for rank of lowest card at the start of the straight22Straight Flush9 choices for rank of lowest card at the start of the straight4 possible suits for the flush22Straight Flush9 choices for rank of lowest card at the start of the straight4 possible suits for the flush9 × 4 = 3622Straight Flush9 choices for rank of lowest card at the start of the straight4 possible suits for the flush9 × 4 = 3652536=362,598,960= 1 in 72,193.333…224 of a Kind234 of a Kind13 choices of rank234 of a Kind13 choices of rank48 choices for remaining card234 of a Kind13 choices of rank48 choices for remaining card13 × 48 = 624234 of a Kind13 choices of rank48 choices for remaining card13 × 48 = 624525624=6242,598,960= 1 in 4,16523Flush24Flush4 choices of suit24Flush4 choices of suit135choices of cards244 × 1287= 5148Flush4 choices of suit135choices of cards244 × 1287= 5148Flush4 choices of suit135choices of cards“but not a straight flush…”244 × 1287= 5148Flush4 choices of suit135choices of cards“but not a straight flush…” - 36 straight flushes244 × 1287= 5148Flush4 choices of suit135choices of cards“but not a straight flush…” - 36 straight flushes5112 flushes244 × 1287= 5148Flush4 choices of suit135choices of cards“but not a straight flush…” - 36 straight flushes5112 flushes5,112= 1 in 508.4…52524Straight259 choices of lowest cardStraight259 × 1024= 92169 choices of lowest card45 choices of suits for 5 cardsStraight259 × 1024= 92169 choices of lowest card45 choices of suits for 5 cards“but not a straight flush…”Straight259 × 1024= 92169 choices of lowest card45 choices of suits for 5 cards“but not a straight flush…” - 36 straight flushesStraight259 × 1024= 92169 choices of lowest card45 choices of suits for 5 cards“but not a straight flush…” - 36 straight flushes9180 straightsStraight259 × 1024= 92169 choices of lowest card45 choices of suits for 5 cards“but not a straight flush…” - 36 straight flushes9180 straights9,180= 1 in 283.06…525Straight25RankingStraight Flush   364-of-a-kind    624Full House    3,744Flush    5,112Straight    9,1803-of-a-kind    54,9122-pair    123,552A pair    1,098,240Nothing    1,302,54026Storing Poker Hands:How many bits per hand?I want to store a 5 card poker hand using the smallest number of bits (space efficient)27Order the 2,598,560 Poker Hands Lexicographically (or in any fixed way)To store a hand all I need is to store its index of size  log2(2,598,560)  = 22 bitsHand 0000000000000000000000Hand 0000000000000000000001Hand 0000000000000000000010...28Is 22 Bits OPTIMAL?29Is 22 Bits OPTIMAL?221 = 2,097,152 < 2,598,56029Is 22 Bits OPTIMAL?221 = 2,097,152 < 2,598,560Thus there are more poker hands than there are 21-bit strings29Is 22 Bits OPTIMAL?221 = 2,097,152 < 2,598,560Thus


View Full Document

CMU CS 15251 - lecture

Documents in this Course
lecture

lecture

66 pages

lecture

lecture

79 pages

lecture

lecture

111 pages

lecture

lecture

85 pages

lecture17

lecture17

64 pages

Lecture

Lecture

85 pages

Lecture

Lecture

71 pages

Lecture

Lecture

70 pages

Lecture

Lecture

11 pages

Lecture

Lecture

45 pages

Lecture

Lecture

50 pages

Lecture

Lecture

93 pages

Lecture

Lecture

93 pages

Lecture

Lecture

35 pages

Lecture

Lecture

98 pages

Lecture

Lecture

74 pages

Lecture

Lecture

13 pages

Lecture

Lecture

15 pages

Lecture

Lecture

66 pages

Lecture

Lecture

82 pages

Lecture

Lecture

15 pages

Lecture

Lecture

47 pages

Lecture

Lecture

69 pages

Lecture

Lecture

13 pages

Lecture

Lecture

67 pages

Lecture

Lecture

68 pages

Lecture

Lecture

69 pages

lecture03

lecture03

44 pages

Lecture

Lecture

69 pages

Lecture

Lecture

68 pages

Lecture

Lecture

55 pages

Lecture

Lecture

79 pages

Lecture

Lecture

85 pages

Lecture

Lecture

87 pages

Lecture

Lecture

85 pages

Lecture

Lecture

103 pages

Lecture

Lecture

9 pages

Lecture

Lecture

83 pages

Lecture

Lecture

8 pages

lecture03

lecture03

68 pages

lecture24

lecture24

78 pages

lecture03

lecture03

72 pages

Thales

Thales

129 pages

lecture13

lecture13

81 pages

Lecture

Lecture

64 pages

lecture01

lecture01

59 pages

lecture11

lecture11

105 pages

Lecture

Lecture

89 pages

Lecture

Lecture

74 pages

lecture25

lecture25

57 pages

Lecture

Lecture

99 pages

lecture

lecture

50 pages

lecture

lecture

14 pages

Lecture

Lecture

78 pages

lecture

lecture

8 pages

Lecture

Lecture

98 pages

lecture

lecture

83 pages

lecture23

lecture23

88 pages

lecture

lecture

64 pages

lecture

lecture

72 pages

Lecture

Lecture

88 pages

lecture

lecture

79 pages

Lecture

Lecture

60 pages

lecture

lecture

74 pages

lecture19

lecture19

72 pages

lecture25

lecture25

86 pages

lecture

lecture

13 pages

lecture17

lecture17

79 pages

lecture

lecture

91 pages

lecture

lecture

78 pages

Lecture

Lecture

11 pages

Lecture

Lecture

54 pages

lecture

lecture

72 pages

lecture

lecture

167 pages

lecture

lecture

73 pages

lecture

lecture

73 pages

lecture

lecture

83 pages

lecture

lecture

49 pages

lecture

lecture

16 pages

lecture

lecture

67 pages

lecture

lecture

81 pages

lecture

lecture

72 pages

lecture

lecture

57 pages

lecture16

lecture16

82 pages

lecture21

lecture21

46 pages

Lecture

Lecture

92 pages

Lecture

Lecture

14 pages

Lecture

Lecture

49 pages

Lecture

Lecture

132 pages

Lecture

Lecture

101 pages

Lecture

Lecture

98 pages

Lecture

Lecture

59 pages

Lecture

Lecture

64 pages

Lecture

Lecture

106 pages

Lecture

Lecture

70 pages

Lecture

Lecture

80 pages

Lecture

Lecture

76 pages

Lecture

Lecture

91 pages

Lecture

Lecture

112 pages

Lecture

Lecture

91 pages

Lecture

Lecture

10 pages

Lecture

Lecture

39 pages

Lecture

Lecture

79 pages

Lecture

Lecture

74 pages

Lecture

Lecture

44 pages

Lecture

Lecture

39 pages

Lecture

Lecture

99 pages

Lecture

Lecture

44 pages

Lecture

Lecture

59 pages

Lecture

Lecture

36 pages

lecture17

lecture17

36 pages

lecture

lecture

71 pages

lecture

lecture

79 pages

lecture

lecture

12 pages

lecture

lecture

43 pages

lecture

lecture

87 pages

lecture

lecture

35 pages

lecture03

lecture03

23 pages

lecture

lecture

68 pages

lecture

lecture

74 pages

lecture

lecture

21 pages

lecture

lecture

79 pages

lecture

lecture

15 pages

lecture

lecture

83 pages

lecture

lecture

13 pages

Lecture

Lecture

53 pages

lecture

lecture

55 pages

lecture

lecture

49 pages

lecture

lecture

10 pages

lecture

lecture

70 pages

lecture

lecture

12 pages

Lecture

Lecture

105 pages

Lecture

Lecture

9 pages

Lecture

Lecture

72 pages

Lecture

Lecture

66 pages

Lecture

Lecture

54 pages

Lecture

Lecture

98 pages

Lecture

Lecture

57 pages

Lecture

Lecture

75 pages

Lecture

Lecture

48 pages

lecture

lecture

53 pages

Lecture

Lecture

72 pages

Lecture

Lecture

53 pages

Lecture

Lecture

84 pages

Lecture

Lecture

55 pages

Lecture

Lecture

15 pages

Lecture

Lecture

6 pages

Lecture

Lecture

38 pages

Lecture

Lecture

71 pages

Lecture

Lecture

110 pages

Lecture

Lecture

70 pages

lecture

lecture

48 pages

lecture

lecture

76 pages

lecture

lecture

48 pages

lecture

lecture

52 pages

lecture

lecture

43 pages

lecture

lecture

81 pages

lecture

lecture

82 pages

lecture

lecture

83 pages

lecture

lecture

64 pages

lecture

lecture

71 pages

lecture

lecture

65 pages

lecture

lecture

56 pages

lecture

lecture

12 pages

lecture

lecture

66 pages

lecture

lecture

50 pages

lecture

lecture

86 pages

lecture

lecture

70 pages

Lecture

Lecture

74 pages

Lecture

Lecture

54 pages

Lecture

Lecture

90 pages

lecture

lecture

78 pages

lecture

lecture

87 pages

Lecture

Lecture

55 pages

Lecture

Lecture

12 pages

lecture21

lecture21

66 pages

Lecture

Lecture

11 pages

lecture

lecture

83 pages

Lecture

Lecture

53 pages

Lecture

Lecture

69 pages

Lecture

Lecture

12 pages

lecture04

lecture04

97 pages

Lecture

Lecture

14 pages

lecture

lecture

75 pages

Lecture

Lecture

74 pages

graphs2

graphs2

8 pages

lecture

lecture

82 pages

Lecture

Lecture

8 pages

lecture

lecture

47 pages

lecture

lecture

91 pages

lecture

lecture

76 pages

lecture

lecture

73 pages

lecture

lecture

10 pages

lecture

lecture

63 pages

lecture

lecture

91 pages

lecture

lecture

79 pages

lecture

lecture

9 pages

lecture

lecture

70 pages

lecture

lecture

86 pages

lecture

lecture

102 pages

lecture

lecture

145 pages

lecture

lecture

91 pages

Lecture

Lecture

87 pages

lecture

lecture

87 pages

Notes

Notes

19 pages

Lecture

Lecture

50 pages

Lecture

Lecture

13 pages

Lecture

Lecture

97 pages

Lecture

Lecture

98 pages

Lecture

Lecture

83 pages

Lecture

Lecture

77 pages

Lecture

Lecture

102 pages

Lecture

Lecture

63 pages

Lecture

Lecture

104 pages

lecture

lecture

41 pages

lecture

lecture

14 pages

Lecture

Lecture

87 pages

Lecture

Lecture

94 pages

lecture

lecture

9 pages

Lecture

Lecture

96 pages

Lecture

Lecture

72 pages

Lecture

Lecture

35 pages

Lecture

Lecture

77 pages

Lecture

Lecture

98 pages

Lecture

Lecture

48 pages

Lecture

Lecture

66 pages

Lecture

Lecture

53 pages

lecture18

lecture18

101 pages

Lecture

Lecture

10 pages

Lecture

Lecture

70 pages

Lecture

Lecture

12 pages

Lecture

Lecture

74 pages

graphs

graphs

10 pages

Lecture

Lecture

62 pages

Lecture

Lecture

11 pages

Lecture

Lecture

71 pages

Lecture

Lecture

42 pages

lecture15

lecture15

72 pages

Lecture

Lecture

82 pages

Load more
Download lecture
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view lecture and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view lecture 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?