CSE390D Notes for Monday, 11/4/24

Basics of Counting: sum rule product rule overcounting (subtraction rule, principle of inclusion-exclusion) decision trees ------------------------------------------------------------------------------- product rule: outcome is a sequence of outcomes from various sets outcome = A1 x A2 x A3 ... x An total = |A1| * |A2| * |A3| ... * |An| example: one of 5 appetizers AND one of 8 entries AND one of 6 desserts total? 5 * 8 * 6 license plates: 3 letters followed by 3 digits answer: 26^3 * 10^3 38 students in a class, 38 chairs, how many arrangements? 38! functions from a set of n elements to a set of m elements? m^n one-to-one functions from a set of n elements to a set of m elements? m * (m-1) * (m-2)... * (m - n +1) = m! / (m-n)! ------------------------------------------------------------------------------- sum rule: outcome is one of a set of disjoint sets outcome = {A1 U A2 U A3 ... U An} total = |A1| + |A2| + |A3| ... + |An| example: one of 3 fish entries OR 2 veggie entries OR 4 meat entries total? 3 + 2 + 4 ------------------------------------------------------------------------------- BASIC variable names variables can be one or two characters long * The first character must be a letter * The second character can be a letter or a digit * The keywords “TO”, “IF”, and “DO” are excluded answer: 26 + 26 * 36 - 3 = 26 * 37 - 3 ------------------------------------------------------------------------------- passwords are 4-6 chars, at least one digit and at least one letter (case insensitive, no special characters): Answer: (4-char pass) = 36^4 (all strings) - 26^4 (no digit) - 10^4 (no letter) (5-char pass) = 36^5 (all strings) - 26^5 (no digit) - 10^5 (no letter) (6-char pass) = 36^6 (all strings) - 26^6 (no digit) - 10^6 (no letter) overall answer is the sum: (4-char pass) + (5-char pass) + (6-char pass) ------------------------------------------------------------------------------- subtraction rule: outcome is one of a set of overlapping sets outcome = A1 U A2 total = |A1| + |A2| - |A1 intersect A2| also called the principle of exclusion-inclusion we overcount, then compensate How many two-digit numbers that begin with even or end with even? (# begin) + (# end) - (# begin & end) = 4 * 10 + 9 * 5 - 4 * 5 = 40 + 45 - 20 = 65 ------------------------------------------------------------------------------- others: subsets of set of n elements? 2^n binary digits of length 8 start with 1 or end with 00? 2^7 + 2^6 - 2^5 class has 40 students, 20 CS, 15 math, 5 dual how many neither math nor cs? #cs/math = 20 + 15 - 5 = 30 non cs/math = 10 best 2 out of 3 for joe/sally...how many outcomes? 6 ss, jj, sjs, jss, jsj, sjs use a tree diagram
Stuart Reges
Last modified: Mon Nov 4 13:30:02 PST 2024