100 likes | 158 Views
Understand the concepts of recursively defined sets in Mathematics and Computer Science, including changes in the recursive step and the definition of different sets over alphabets. Explore data structures and counting techniques using product rule, sum rule, and inclusion-exclusion principle.
E N D
Math/CSE 1019N:Discrete Mathematics for Computer ScienceWinter 2007 Suprakash Datta datta@cs.yorku.ca Office: CSEB 3043 Phone: 416-736-2100 ext 77875 Course page: http://www.cs.yorku.ca/course/1019
Recursively defined sets • Basis step: 2 S • Recursive step: If x S and y S then x+ y S Defines the set {2k|k=1,2,3,…} What happens if we change the recursive step to: If x S and y S then x+y S, x-y S ?
Recursively defined sets - 2 All possible strings (*) over alphabet • Basis step: * • Recursive step: If x and w * then wx * Length of a string l() = 0 l(wx) = l(w) + 1 if x and w *
Recursively defined sets - 3 What is this set A definedover = {0,1}? • Basis step: A • Recursive step: If x A then 0x1 A What is this set B definedover = {0,1}? • Basis step: B • Recursive step: If x B then 0x1 B and 1x0 B
Recursively defined sets - 4 Data structures – full binary trees • Basis step: single vertex • Recursive step: If S, T are full binary trees then the following is a full binary tree r T S
Next: counting • Basic tool in Computer Science, Discrete Mathematics, Probability
Product rule • Two tasks, n1 ways of doing first, and for each of those n1 ways, n2 ways of doing the second. • Generalizes to n tasks E.g.: • 2 dice rolls • # of binary strings of length k • Cardinality of the power set of a finite set • #of postal address codes
Sum rule • If a task can be done in one of n1 ways or one of n2 ways and the sets of n1 and n2 ways are disjoint, then it can be done in n1 + n2 ways. E.g.: • Choosing an elective • Number of offices in CSEB • Number of CS majors at York • Number of binary strings of length 4 containing exactly one 1.
More complex counting • Maximum possible number of (land) phone numbers in Toronto. • Number of binary strings starting with 1 and having at most 4 digits. • Number of positive integers with 4 digits and exactly one 1 (allow leading zeroes). • Number of alphanumeric strings with at least one digit.
Inclusion- exclusion principle • Two dice – first toss is a 1 or last toss is a 6 A = 1* B = *6 A B |A B| = |A| + |B| - |A B|