Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
CSC-2259 Discrete Structures Konstantin Busch Louisiana State University K. Busch - LSU 1 Topics to be covered • • • • • • • Logic and Proofs Sets, Functions, Sequences, Sums Integers, Matrices Induction, Recursion Counting Discrete Probability Graphs K. Busch - LSU 2 Binary Arithmetic Decimal Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Numbers: 9, 28, 211, etc Binary Digits: 0, 1 (also known as bits) Numbers: 1001, 11100, 11010011, etc K. Busch - LSU 3 Binary Decimal 1001 9 1 2 0 2 0 2 1 2 8 1 9 3 2 1 K. Busch - LSU 0 4 Binary Addition 1001 (9) + 1 1 (3) -----1100 (12) Binary Multiplication 1001 (9) x 1 1 (3) -----1001 + 1001 --------11011 (27) K. Busch - LSU 5 Binary Logic AND Gates OR x y z x y z 0 0 0 0 0 0 0 1 0 0 1 1 1 0 0 1 0 1 1 1 1 1 1 1 x y z AND x y NOT z OR K. Busch - LSU x z 0 1 1 0 x z NOT 6 An arbitrary binary function is implemented with NOT, AND, and OR gates f ( x1 , x2 ,, xn ) y x1 x2 x2 y … OR xn NOT AND K. Busch - LSU 7 Propositional Logic Proposition: a declarative sentence which is either True or False Examples: Today is Wednesday Today it Snows 1+1 = 2 1+1 = 1 H20 = water K. Busch - LSU (False) (False) (True) (False) (True) 8 We can map to binary values: True = 1 False = 0 Propositions can be combined using the binary operators AND, OR, NOT Example: ( p q) (a (b c)) K. Busch - LSU 9 Implication y x y x True True True True False False False True True False False True x implies y x y “You get a computer science degree only if you are a computer science major” x : You get a computer science degree y : You are a computer science major K. Busch - LSU 10 Bi-conditional y x y x True True True True False False False True False False False True x if and only if y x y “There is a received phone call if and only if there is a phone ring” There is a received phone call y : There is a phone ring x: K. Busch - LSU 11 Sets Set is a collection of elements: Real numbers R Integers Z Empty Set Students in this room K. Busch - LSU 12 Basic Set Operations Subset {2,4} {1,2,3,4,5} 1 3 2 4 5 Union {1,2,3} {2,4,5} {1,2,3,4,5} 3 1 2 4 5 K. Busch - LSU 13 {1,2,3} {2,4,5} {2} Intersection 3 1 2 4 5 Complement {1,4} {2,3,5} universe {1,2,3,4,5} K. Busch - LSU 14 DeMorgan’s Laws A B A B A B A B K. Busch - LSU 15 Inclusion-Exclusion | A B C | | A| | B | | C | | A B | | AC | | B C | | A BC| A B C K. Busch - LSU 16 Powersets Contains all subsets of a set A {1,2,3} Powerset of A Q {,{1},{2},{3},{1,2},{2,3},{1,3},{1,2,3}} | Q | 2 | A| K. Busch - LSU 17 Counting Suppose we are given four objects: a, b, c, d How many ways are there to order the objects? 4! 1 2 3 4 a,b,c,d b,a,c,d a,b,d,c b,a,d,c … and so on K. Busch - LSU 18 Combinations Given a set S with n elements how many subsets exist with m elements? n n! m m!(n m)! Example: S {1,2,3} 3 3! 3 2 2!(3 2)! {1,2},{2,3},{1,3} K. Busch - LSU 19 Sterling’s Approximation n n! 2n e K. Busch - LSU n 20 Probabilities What is the probability the a dice gives 5? Event set = {5} Sample space = {1,2,3,4,5,6} Size of event set 1 Pr obability( {5}) Size of sample space 6 K. Busch - LSU 21 What is the probability that two dice give the same number? Event set = {{1,1},{2,2},{3,3},{4,4},{5,5},{6,6}} Sample Space = {{1,1},{1,2},{1,3}, …., {6,5}, {6,6}} Size of event set 6 Pr obability( {same number}) Size of sample space 36 K. Busch - LSU 22 Randomized Algorithms Quicksort(A): If ( |A| == 1) return the one item in A Else p = RandomElement(A) L = elements less than p H = elements higher than p B = Quicksort(L) C = Quicksort(H) return(BC) K. Busch - LSU 23 Graph Theory San Francisco 800 700 2000 miles 1500 miles 300 1500 Las Vegas 1500 Chicago 1000 1500 1000 1000 2000 Los Angeles Boston New York 800 Atlanta 700 Baton Rouge 1500 Miami K. Busch - LSU 24 Shortest Path from Los Angeles to Boston 1500 2000 800 1500 1500 1000 700 1500 1000 300 Boston 800 1000 700 2000 1500 Los Angeles K. Busch - LSU 25 Maximum number of edges in a graph with n nodes: 2 n n! n(n 1) n n 2 2 2 2!(n 2)! n5 edges 10 Clique with five nodes K. Busch - LSU 26 Other interesting graphs Trees Bipartite Graph K. Busch - LSU 27 Recursion Sum of arithmetic sequence f (n ) 1 2 3 4 (n 1) n f (n ) n f (n 1) Basis f (1) 1 Sum of geometric sequence f (n ) 20 21 22 23 2(n 1) Basis f (n ) 2 f (n 1) 1 f (1) 1 K. Busch - LSU 28 Fibonacci numbers Basis f (n ) f n 1 f (n 2) f (0) 0, f (1) 1 Divide and conquer algorithms (Quicksort) n f (n ) 2 f n 2 f (1) 1 K. Busch - LSU 29 Proof Techniques Induction Contradiction Pigeonhole principle K. Busch - LSU 30 Proof by Induction f (n ) n f (n 1) n (n 1) Prove: f (n ) 2 1(1 1) Induction Basis: f (1) 1 2 Induction Hypothesis: (n 1)n f (n 1) 2 Induction Step: (n 1)n n 2 n n (n 1) f (n ) n f (n 1) n 2 2 2 K. Busch - LSU 31 Proof by Contradiction is irrational 2 Suppose m2 2 2 n 2 n2 = 4k2 m 2 n ( m and n have no common divisor greater than 1 ) m2 is even n2 = 2k2 m=2k m is even n is even Contradiction K. Busch - LSU 32