UCSD CSE 21, Spring 2014 [Section B00] Mathematics for Algorithm and System Analysis

Similar documents
CSE 21 Mathematics for Algorithm and System Analysis

Introductory Probability

Jong C. Park Computer Science Division, KAIST

With Question/Answer Animations. Chapter 6

Counting integral solutions

Block 1 - Sets and Basic Combinatorics. Main Topics in Block 1:

Lecture 18 - Counting

It is important that you show your work. The total value of this test is 220 points.

Week 1: Probability models and counting

Counting in Algorithms

Counting. Chapter 6. With Question/Answer Animations

CS70: Lecture Review. 2. Stars/Bars. 3. Balls in Bins. 4. Addition Rules. 5. Combinatorial Proofs. 6. Inclusion/Exclusion

n! = n(n 1)(n 2) 3 2 1

The Product Rule The Product Rule: A procedure can be broken down into a sequence of two tasks. There are n ways to do the first task and n

Topics to be covered

CS100: DISCRETE STRUCTURES. Lecture 8 Counting - CH6

CSE 312: Foundations of Computing II Quiz Section #2: Inclusion-Exclusion, Pigeonhole, Introduction to Probability (solutions)

Reading 14 : Counting

Class 8 - Sets (Lecture Notes)

Lecture 2: Sum rule, partition method, difference method, bijection method, product rules

In how many ways can we paint 6 rooms, choosing from 15 available colors? What if we want all rooms painted with different colors?

Multiple Choice Questions for Review

Compound Probability. Set Theory. Basic Definitions

1. Counting. 2. Tree 3. Rules of Counting 4. Sample with/without replacement where order does/doesn t matter.

POKER (AN INTRODUCTION TO COUNTING)

DVA325 Formal Languages, Automata and Models of Computation (FABER)

CS1802 Week 6: Sets Operations, Product Sum Rule Pigeon Hole Principle (Ch )

Sets. Definition A set is an unordered collection of objects called elements or members of the set.

Chapter 2. Permutations and Combinations

Lecture 14. What s to come? Probability. A bag contains:

Slide 1 Math 1520, Lecture 13

CSE 312: Foundations of Computing II Quiz Section #2: Inclusion-Exclusion, Pigeonhole, Introduction to Probability

ON SPLITTING UP PILES OF STONES

Section Summary. Finite Probability Probabilities of Complements and Unions of Events Probabilistic Reasoning

Combinatorial Proofs

MAT 243 Final Exam SOLUTIONS, FORM A

Notes for Recitation 3

UCSD CSE 21, Spring 2014 [Section B00] Mathematics for Algorithm and System Analysis

8.2 Union, Intersection, and Complement of Events; Odds

Problem Set 8 Solutions R Y G R R G

The study of probability is concerned with the likelihood of events occurring. Many situations can be analyzed using a simplified model of probability

1 = 3 2 = 3 ( ) = = = 33( ) 98 = = =

Mat 344F challenge set #2 Solutions

Discrete Mathematics with Applications MATH236

Section Summary. Permutations Combinations Combinatorial Proofs

MATHEMATICS 152, FALL 2004 METHODS OF DISCRETE MATHEMATICS Outline #10 (Sets and Probability)

Discrete Structures Lecture Permutations and Combinations

CSCI 2200 Foundations of Computer Science (FoCS) Solutions for Homework 7

Discrete Structures for Computer Science

ACHS Math Team Lecture: Introduction to Set Theory Peter S. Simon

Solution: This is sampling without repetition and order matters. Therefore

Honors Precalculus Chapter 9 Summary Basic Combinatorics

Permutations and Combinations

The next several lectures will be concerned with probability theory. We will aim to make sense of statements such as the following:

The Product Rule can be viewed as counting the number of elements in the Cartesian product of the finite sets

Problem 2A Consider 101 natural numbers not exceeding 200. Prove that at least one of them is divisible by another one.

CMath 55 PROFESSOR KENNETH A. RIBET. Final Examination May 11, :30AM 2:30PM, 100 Lewis Hall

Probability (Devore Chapter Two)

TOPOLOGY, LIMITS OF COMPLEX NUMBERS. Contents 1. Topology and limits of complex numbers 1

CSE 312: Foundations of Computing II Quiz Section #2: Combinations, Counting Tricks (solutions)

PROBABILITY FOR RISK MANAGEMENT. Second Edition

Combinatorics and Intuitive Probability

CSE 312 Midterm Exam May 7, 2014

9.5 Counting Subsets of a Set: Combinations. Answers for Test Yourself

CSE 21: Midterm 1 Solution

Discrete Structures for Computer Science

Chapter 1. Probability

Midterm practice super-problems

Chapter 5: Probability: What are the Chances? Section 5.2 Probability Rules

6.1 Basics of counting

The topic for the third and final major portion of the course is Probability. We will aim to make sense of statements such as the following:

Introduction to Counting and Probability

Tutorial 1. (ii) There are finite many possible positions. (iii) The players take turns to make moves.

BRITISH COLUMBIA SECONDARY SCHOOL MATHEMATICS CONTEST, 2006 Senior Preliminary Round Problems & Solutions

Problem Set 8 Solutions R Y G R R G

Cardinality. Hebrew alphabet). We write S = ℵ 0 and say that S has cardinality aleph null.

2. Combinatorics: the systematic study of counting. The Basic Principle of Counting (BPC)

Sec$on Summary. Permutations Combinations Combinatorial Proofs

CIS 2033 Lecture 6, Spring 2017

Graphs of Tilings. Patrick Callahan, University of California Office of the President, Oakland, CA

HOMEWORK ASSIGNMENT 5

Principle of Inclusion-Exclusion Notes

Combinatorics: The Fine Art of Counting

The Classification of Quadratic Rook Polynomials of a Generalized Three Dimensional Board

Outline. Content The basics of counting The pigeonhole principle Reading Chapter 5 IRIS H.-R. JIANG

FOURTH LECTURE : SEPTEMBER 18, 2014

POLYA'S FOUR STEP PROBLEM SOLVING PROCESS Understand. Devise a Plan. Carry out Plan. Look Back. PROBLEM SOLVING STRATEGIES (exmples) Making a Drawlnq

Combinatorics: The Fine Art of Counting

Sec 5.1 The Basics of Counting

12. 6 jokes are minimal.

Sec.on Summary. The Product Rule The Sum Rule The Subtraction Rule (Principle of Inclusion- Exclusion)

Counting and Probability Math 2320

Mathematics Competition Practice Session 6. Hagerstown Community College: STEM Club November 20, :00 pm - 1:00 pm STC-170

CS103 Handout 25 Spring 2017 May 5, 2017 Problem Set 5

Final Exam, Math 6105

Senior Math Circles February 10, 2010 Game Theory II

CSE 21 Math for Algorithms and Systems Analysis. Lecture 2 Lists Without Repe>>on

The probability set-up

Unit Nine Precalculus Practice Test Probability & Statistics. Name: Period: Date: NON-CALCULATOR SECTION

DISCUSSION #8 FRIDAY MAY 25 TH Sophie Engle (Teacher Assistant) ECS20: Discrete Mathematics

Transcription:

UCSD CSE 21, Spring 2014 [Section B00] Mathematics for Algorithm and System Analysis Lecture 3 Class URL: http://vlsicad.ucsd.edu/courses/cse21-s14/

Lecture 3 Notes Goal for today: CL Section 3 Subsets, Binomial Coefficients (poker hands, loop iterations) Thanks to Dr. Rubalcaba for giving this lecture (I hope I am in Germany when you see this) No office hours tomorrow (Wednesday) (I hope I am flying back from Germany at that point) New reader-tutors Kacy Raye Espinoza (krespino@ucsd.edu) and Tracy Nham (tnham@ucsd.edu) Will hold extra OH s and help sessions, and can also provide 1-1 or small-group help Please contact them to schedule (please cc instructors) We re adding more to the team as fast as we can

Last Week on One Slide Theorem 1: k-lists out of n-set with replacement Theorem 4: k-lists out of n-set without replacement Theorem 7: k-subsets out of n-set Recall number of k-lists from n-set without repetition: n! / (n k)! k-list vs. k-subset : each subset is listed in k! ways Theorem 7: number of k-lists of n-set: n! / [(n k)! k!] These are combinations of n objects taken k at a time Also written C(n,k) ( n choose k )

Theorems 1, 4, 7 Given: 5-set S = {v, w, x, y, z} How many 3-lists can be formed from elements of S, with repetition? [ ordering : order matters, with repetition] Theorem 1 5 3 = 125 How many 3-lists can be formed from elements of S, without repetition? [ ordering : order matters, without repetition] Theorem 4 5! / (5 3)! = 5 4 3 = 60 How many 3-sets are subsets of S? [ selecting / choosing : order doesn t matter, without repetition] Theorem 7 5! / [(5 3)! 3!] = 10

Last Week on One Slide Theorem 1: k-lists out of n-set with replacement Theorem 4: k-lists out of n-set without replacement Theorem 7: k-subsets out of n-set without replacement Rule of Product (Theorem 2): If structures are constructed by making a sequence of k choices such that the i th choice can be made in c i ways (independently of previous choices), and each structure arises in exactly one way, then there are c 1 c 2 c k possible structures. Sets C 1,, C k have Cartesian product C 1 C 2 C k with elements (x 1,x 2,,x k ) where x i C i, i = 1,, k Lexicographic order = dictionary order

Last Week on One Slide Theorem 1: k-lists out of n-set with replacement Theorem 4: k-lists out of n-set without replacement Theorem 7: k-subsets out of n-set without replacement Rule of Product (Theorem 2): If structures are constructed by making a sequence of k choices such that the i th choice can be made in c i ways (independently of previous choices), and each structure arises in exactly one way, then there are c 1 c 2 c k possible structures. Sets C 1,, C k have Cartesian product C 1 C 2 C k with elements (x 1,x 2,,x k ) where x i C i, i = 1,, k Lexicographic order = dictionary order Rule of Sum (Theorem 3): The cardinality of the union of disjoint sets is the sum of cardinalities of those sets

Loop Iterations Example: Counting Loop Iterations What is the value of k after the following code has been executed? k = 0; for i 1 = 1 to n 1 for i 2 = 1 to n 2 for i 3 = 1 to n 3 k = k + 1; A: (n 1 ) 3 B: n 1 n 2 n 3 C: (n 2 ) 3 D: n 1 + n 2 + n 3 E: n (n 1) / 2

Loop Iterations Example: Counting Loop Iterations What is the value of k after the following code has been executed? k = 0; for i 1 = 1 to n 1 k = k + 1; for i 2 = 1 to n 2 k = k + 1; A: (n 1 ) 3 B: n 1 n 2 n 3 C: (n 2 ) 3 D: n 1 + n 2 + n 3 E: n (n 1) / 2 for i 3 = 1 to n 3 k = k + 1;

Loop Iterations Example: Counting Loop Iterations What is the value of k after the following code has been executed? k = 0; for i 1 = 1 to n for i 2 = i 1 +1 to n k = k + 1; A: (n 1 ) 3 B: n 1 n 2 n 3 C: (n 2 ) 3 D: n 1 + n 2 + n 3 E: n (n 1) / 2

Poker Hands 5-card poker hands from standard 52-card deck http://en.wikipedia.org/wiki/poker_probability/ 52 cards = {4 suits} x {13 ranks} Suits =,,, Ranks = 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K, A [A = highest] How many 5-card poker hands? C(52,5) = 2598960 How many poker hands have 4 of a kind == 4 cards of one rank + 1 card of another rank? A: C(52,4) B: C(13,1) C(12,1) 5! C: C(13,1) 48 D: C(13,2) 5! E: C(13,2) 48

1-Pair Poker Hands (review this off-line) How many 5-card poker hands have exactly one pair? Note: K-K-10-7-3 has one pair and should be counted, but K-K-K-10-7 (three of a kind) or K-K-10-10-7 (two pair) should not be counted) Solution A. You can pick the first card in 52 ways. You can pick its pair in 3 ways. This overcounts the #ways we can arrive at the pair by a factor of 2! = 2. You can pick each of the next three cards (so as to avoid 3-of-a-kind or two pairs) in 48, 44 and 40 ways, respectively. This overcounts the #ways we can arrive at these three cards by a factor of 3! = 6. The answer is 52 x 3 x 48 x 44 x 40 / (2 x 6) = 1,098,240.

1-Pair Poker Hands (review this off-line) How many 5-card poker hands have exactly one pair? Note: K-K-10-7-3 has one pair and should be counted, but K-K-K-10-7 (three of a kind) or K-K-10-10-7 (two pair) should not be counted) Solution B. You can pick the four ranks in a one-pair hand in C(13,4) = 715 ways. You can pick the rank that has the pair in C(4,1) = 4 ways (choose one rank out of four). Within this rank that has the pair, you can pick the actual pair in C(4,2) = 6 ways (e.g., if the rank is Q, then you can pick Q and Q ). For each of the other three ranks, you can pick the actual card in C(4,1) = 4 ways. The answer is 715 x 4 x 6 x 4 x 4 x 4 = 1,098,240.

1-Pair Poker Hands (review this off-line) How many 5-card poker hands have exactly one pair? Note: K-K-10-7-3 has one pair and should be counted, but K-K-K-10-7 (three of a kind) or K-K-10-10-7 (two pair) should not be counted) Solution C. You can pick the one rank containing the pair in C(13,1) = 13 ways. The actual pair of cards can be chosen from this rank in C(4,2) = 6 ways. You can pick the three other ranks in C(12,3) = 220 ways. The actual cards in the other three ranks can be chosen in 4 x 4 x 4 ways. The answer is 13 x 6 x 220 x 4 x 4 x 4 = 1,098,240.

Counting Problem Examples from Week 1 A Common Problem Type How many integer solutions are there to the equation x 1 + x 2 + x 3 + x 4 = 12, with x i 0? How do we apply the Order Form Method? How many solutions are there with x i > 0?

Counting Problem Examples from Week 1 A Common Problem Type How many integer solutions are there to the equation x 1 + x 2 + x 3 + x 4 = 12, with x i 0? How do we apply the Order Form Method? How many solutions are there with x 1 2, x 2 2, x 3 4, x 4 0?

Counting Problem Examples from Week 1 Licorice How many ways are there to distribute 20 (identical) sticks of red licorice and 15 (identical) sticks of black licorice among five children?

Counting Problem Examples from Week 1 Case analysis How many 4-digit campus telephone numbers have one or more repeated digits? Cases:

Counting Problem Examples from Week 1 Simplification; Counting the Complement How many ways are there to pick a collection of 10 balls from a pile of red balls, blue balls, and purple balls if at least 5 red balls must be picked? Simplification: What if at most 5 red balls must be picked?

Counting Problem Examples from Week 1 Bob has three great books, four trashy books, and two educational books. He picks one great book, two trashy books and one educational book to take on the family camping trip. Bob s mother never lets him read two trashy books in a row. During the trip, Bob read all four books. In how many possible ways could Bob have chosen and read those books?

Counting Problem Examples from Week 1 In how many ways can Bob the dog breeder separate his 10 puppies into a group of 4 and a group of 6, if he has to keep Biter and Nipper, two of the puppies, in separate groups?

Counting Problem Examples from Week 1 Bob the salesman starts at his home in San Diego, and tours 6 cities (Abilene, Bakersfield, Corona, Denver, Eastville and Frankfort), visiting each city exactly once before returning home. In how many possible ways could Bob make his tour? In how many possible ways could Bob make his tour if he does not travel directly between San Diego and Frankfort?

Problems 3: Induction, Extremal Arguments P3.1 What is the error in the following induction proof? Claim: All horses are of the same color. Proof by mathematical induction (on the size of a group of horses). Base case (n = 1). Consider a group of horses of size 1, i.e., a single horse. All the horses in this group are clearly of the same color. Induction hypothesis. Any group of k horses is of the same color. Induction step. Consider a group of k+1 horses. Take out one of the horses, say H 1, leaving k horses H 2,, H k+1. By the induction hypothesis, all of these k horses are of the same color C. Now take a different horse, say H 3, leaving k horses H 1, H 2, H 4,, H k+1. Again by the induction hypothesis, all of these horses are of the same color, C. But since the groups overlap, the colors C and C must be the same, and hence all k+1 horses are of the same color. Since we have proved that a group of horses of any size is of a single color, and there exist only a finite number of horses on the planet, we have that all horses must be of the same color.

Problems 3: Induction, Extremal Arguments P3.2 Into at most how many parts is a plane cut by n lines? (Give your answer as an expression in n, and justify.) P3.3 There are n points given in the plane. Any three of the points form a triangle of area 1. Explain why all n points must lie in a triangle of area 4. P3.4 You are given 2n points are given in the Euclidean plane, with no three of these points collinear. Exactly n of these points are farms F = {F 1, F 2, F n }. The other n points are wells W = {W 1, W 2,, W n }. Explain why it is possible to build n straight-line roads that connect each farm to exactly one well, and each well to exactly one farm (notice that the roads define a 1-to-1 correspondence between the sets F and W), such that none of the roads intersect.