DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005.

Slides:



Advertisements
Similar presentations
CSNB143 – Discrete Structure
Advertisements

Chapter Matrices Matrix Arithmetic
Applied Informatics Štefan BEREŽNÝ
Recursively Defined Functions
Mathematics. Matrices and Determinants-1 Session.
Recursive Definitions Rosen, 3.4 Recursive (or inductive) Definitions Sometimes easier to define an object in terms of itself. This process is called.
Recursive Definitions Rosen, 3.4 Recursive (or inductive) Definitions Sometimes easier to define an object in terms of itself. This process is called.
Matrices MSU CSE 260.
MATRICES. Matrices A matrix is a rectangular array of objects (usually numbers) arranged in m horizontal rows and n vertical columns. A matrix with m.
ECON 1150 Matrix Operations Special Matrices
Chapter 3: The Fundamentals: Algorithms, the Integers, and Matrices
Discrete Mathematics Transparency No. 0-1 Discrete Mathematics Cheng-Chia Chen September 2009.
DISCRETE COMPUTATIONAL STRUCTURES CSE 2353 Summer 2005.
Discrete Mathematical Structures (Counting Principles)
April 10, 2002Applied Discrete Mathematics Week 10: Relations 1 Counting Relations Example: How many different reflexive relations can be defined on a.
1 The Chinese University of Hong Kong Faculty of Education Diploma in Education (Part-Time) Winter 1997 Educational Communications and Technology Assignment.
Chapter 10 (Part 2): Boolean Algebra  Logic Gates (10.3) (cont.)  Minimization of Circuits (10.4)
CS 250, Discrete Structures, Fall 2011 Nitesh Saxena
Fall 2002CMSC Discrete Structures1 One, two, three, we’re… Counting.
Copyright © 2011 Pearson, Inc. 7.2 Matrix Algebra.
Lecture 7 Matrices CSCI – 1900 Mathematics for Computer Science Fall 2014 Bill Pine.
Chapter 4 – Matrix CSNB 143 Discrete Mathematical Structures.
If A and B are both m × n matrices then the sum of A and B, denoted A + B, is a matrix obtained by adding corresponding elements of A and B. add these.
1 Closures of Relations: Transitive Closure and Partitions Sections 8.4 and 8.5.
Matrices Matrices A matrix (say MAY-trix) is a rectan- gular array of objects (usually numbers). An m  n (“m by n”) matrix has exactly m horizontal.
2009/9 1 Matrices(§3.8)  A matrix is a rectangular array of objects (usually numbers).  An m  n (“m by n”) matrix has exactly m horizontal rows, and.
Module #9: Matrices Rosen 5 th ed., §2.7 Now we are moving on to matrices, section 7.
Meeting 18 Matrix Operations. Matrix If A is an m x n matrix - that is, a matrix with m rows and n columns – then the scalar entry in the i th row and.
2 2.1 © 2012 Pearson Education, Inc. Matrix Algebra MATRIX OPERATIONS.
Matrices Section 2.6. Section Summary Definition of a Matrix Matrix Arithmetic Transposes and Powers of Arithmetic Zero-One matrices.
Matrices: Simplifying Algebraic Expressions Combining Like Terms & Distributive Property.
Chapter 2 … part1 Matrices Linear Algebra S 1. Ch2_2 2.1 Addition, Scalar Multiplication, and Multiplication of Matrices Definition A matrix is a rectangular.
Matrix Operations.
CSNB143 – Discrete Structure Topic 3 – Matrices. Learning Outcomes Students should understand all matrices operations. Students should be able to differentiate.
Module #9 – Number Theory 1/5/ Algorithms, The Integers and Matrices.
CompSci 102 Discrete Math for Computer Science February 7, 2012 Prof. Rodger Slides modified from Rosen.
Greatest Common Divisors & Least Common Multiples  Definition 4 Let a and b be integers, not both zero. The largest integer d such that d|a and d|b is.
MATRIX A set of numbers arranged in rows and columns enclosed in round or square brackets is called a matrix. The order of a matrix gives the number of.
Section 2.4. Section Summary  Sequences. o Examples: Geometric Progression, Arithmetic Progression  Recurrence Relations o Example: Fibonacci Sequence.
Matrix Operations McDougal Littell Algebra 2 Larson, Boswell, Kanold, Stiff Larson, Boswell, Kanold, Stiff Algebra 2: Applications, Equations, Graphs Algebra.
If A and B are both m × n matrices then the sum of A and B, denoted A + B, is a matrix obtained by adding corresponding elements of A and B. add these.
Matrix Algebra Definitions Operations Matrix algebra is a means of making calculations upon arrays of numbers (or data). Most data sets are matrix-type.
Lecture 21: Combinatorial Circuits II Discrete Mathematical Structures: Theory and Applications.
Introductory Lecture. What is Discrete Mathematics? Discrete mathematics is the part of mathematics devoted to the study of discrete (as opposed to continuous)
CS 285- Discrete Mathematics Lecture 11. Section 3.8 Matrices Introduction Matrix Arithmetic Transposes and Power of Matrices Zero – One Matrices Boolean.
Matrix Operations McDougal Littell Algebra 2 Larson, Boswell, Kanold, Stiff Larson, Boswell, Kanold, Stiff Algebra 2: Applications, Equations, Graphs Algebra.
A very brief introduction to Matrix (Section 2.7) Definitions Some properties Basic matrix operations Zero-One (Boolean) matrices.
MATRICES A rectangular arrangement of elements is called matrix. Types of matrices: Null matrix: A matrix whose all elements are zero is called a null.
2.1 Matrix Operations 2. Matrix Algebra. j -th column i -th row Diagonal entries Diagonal matrix : a square matrix whose nondiagonal entries are zero.
CHAPTER 7 Determinant s. Outline - Permutation - Definition of the Determinant - Properties of Determinants - Evaluation of Determinants by Elementary.
CSE15 Discrete Mathematics 03/01/17
CSE 504 Discrete Mathematics & Foundations of Computer Science
Chapter 11 (Part 1): Boolean Algebra
Chapter 7: Counting Principles
Discrete Structures – CNS2300
Matrix Operations Monday, August 06, 2018.
Dr. Ameria Eldosoky Discrete mathematics
Sequences and Summations
Matrix Algebra.
2. Matrix Algebra 2.1 Matrix Operations.
Closures of Relations: Transitive Closure and Partitions
Lecture 20: Combinatorial Circuits I
DISCRETE COMPUTATIONAL STRUCTURES
CS100: Discrete structures
Chapter 10.3 and 10.4: Combinatorial Circuits
Matrix Algebra.
DISCRETE COMPUTATIONAL STRUCTURES
3.5 Perform Basic Matrix Operations
DETERMINANT MATH 80 - Linear Algebra.
Applied Discrete Mathematics Week 4: Functions
Presentation transcript:

DISCRETE COMPUTATIONAL STRUCTURES CS Fall 2005

CS OUTLINE 9.Matrices & Closures 10.Counting Principles 11.Discrete Probability 12.Congruences 13.Recurrence Relations 14.Algorithm Complexity 15.Graph Theory 16.Trees & Networks 17.Grammars & Languages 1.Sets 2.Logic 3.Proof Techniques 4.Algorithms 5.Integers & Induction 6.Relations & Posets 7.Functions 8.Boolean Algebra & Combinatorial Circuits

Discrete Mathematical Structures: Theory and Applications 3 Learning Objectives  Learn about Boolean expressions  Become aware of the basic properties of Boolean algebra  Explore the application of Boolean algebra in the design of electronic circuits  Learn the application of Boolean algebra in switching circuits

Discrete Mathematical Structures: Theory and Applications 4 Two-Element Boolean Algebra Let B = {0, 1}.

Discrete Mathematical Structures: Theory and Applications 5 Two-Element Boolean Algebra

Discrete Mathematical Structures: Theory and Applications 6

7

8

9 Two-Element Boolean Algebra

Discrete Mathematical Structures: Theory and Applications 10 Two-Element Boolean Algebra

Discrete Mathematical Structures: Theory and Applications 11

Discrete Mathematical Structures: Theory and Applications 12 Minterm

Discrete Mathematical Structures: Theory and Applications 13

Discrete Mathematical Structures: Theory and Applications 14 Maxterm

Discrete Mathematical Structures: Theory and Applications 15

Discrete Mathematical Structures: Theory and Applications 16

Discrete Mathematical Structures: Theory and Applications 17

Discrete Mathematical Structures: Theory and Applications 18 Boolean Algebra

Discrete Mathematical Structures: Theory and Applications 19 Boolean Algebra

Discrete Mathematical Structures: Theory and Applications 20 Logical Gates and Combinatorial Circuits

Discrete Mathematical Structures: Theory and Applications 21 Logical Gates and Combinatorial Circuits

Discrete Mathematical Structures: Theory and Applications 22 Logical Gates and Combinatorial Circuits

Discrete Mathematical Structures: Theory and Applications 23 Logical Gates and Combinatorial Circuits

Discrete Mathematical Structures: Theory and Applications 24

Discrete Mathematical Structures: Theory and Applications 25

Discrete Mathematical Structures: Theory and Applications 26

Discrete Mathematical Structures: Theory and Applications 27

Discrete Mathematical Structures: Theory and Applications 28

Discrete Mathematical Structures: Theory and Applications 29

Discrete Mathematical Structures: Theory and Applications 30

Discrete Mathematical Structures: Theory and Applications 31

Discrete Mathematical Structures: Theory and Applications 32

Discrete Mathematical Structures: Theory and Applications 33

Discrete Mathematical Structures: Theory and Applications 34

Discrete Mathematical Structures: Theory and Applications 35

Discrete Mathematical Structures: Theory and Applications 36

Discrete Mathematical Structures: Theory and Applications 37

Discrete Mathematical Structures: Theory and Applications 38

Discrete Mathematical Structures: Theory and Applications 39

Discrete Mathematical Structures: Theory and Applications 40 Logical Gates and Combinatorial Circuits  The Karnaugh map, or K-map for short, can be used to minimize a sum-of-product Boolean expression.

Discrete Mathematical Structures: Theory and Applications 41

Discrete Mathematical Structures: Theory and Applications 42

Discrete Mathematical Structures: Theory and Applications 43

CS OUTLINE 9.Matrices & Closures 10.Congruences 11.Counting Principles 12.Discrete Probability 13.Recurrence Relations 14.Algorithm Complexity 15.Graph Theory 16.Trees & Networks 17.Grammars & Languages 1.Sets 2.Logic 3.Proof Techniques 4.Algorithms 5.Integers & Induction 6.Relations & Posets 7.Functions 8.Boolean Algebra & Combinatorial Circuits

Discrete Mathematical Structures: Theory and Applications 45 Learning Objectives  Learn about matrices and their relationship with relations  Become familiar with Boolean matrices  Learn the relationship between Boolean matrices and different closures of a relation  Explore how to find the transitive closure using Warshall’s algorithm

Discrete Mathematical Structures: Theory and Applications 46 Matrices

Discrete Mathematical Structures: Theory and Applications 47 Matrices

Discrete Mathematical Structures: Theory and Applications 48 Matrices – terms : equal, square

Discrete Mathematical Structures: Theory and Applications 49 Matrices- terms: zero matrix, diagonal elements

Discrete Mathematical Structures: Theory and Applications 50 Matrices- terms: diagonal matrix, identity matrix

Discrete Mathematical Structures: Theory and Applications 51 Matrices – Matrix Sum  Two matrices are added only if they have the same number of rows and the same number of columns  To determine the sum of two matrices, their corresponding elements are added

Discrete Mathematical Structures: Theory and Applications 52 Matrices – Matrix Addition Example

Discrete Mathematical Structures: Theory and Applications 53 Matrices- Multiply a Constant x Matrix

Discrete Mathematical Structures: Theory and Applications 54 Matrices – Matrix Difference

Discrete Mathematical Structures: Theory and Applications 55 Matrices - Properties Commutative and Associative properties of Matrix addition Distributive property of multiplication over addition ( subtraction ) -only holds for a constant time a matrix sum (difference)

Discrete Mathematical Structures: Theory and Applications 56 Matrices  The multiplication AB of matrices A and B is defined only if the number of columns of A is the same as the number of rows of B

Discrete Mathematical Structures: Theory and Applications 57 Matrices  Let A = [a ij ] m×n be an m × n matrix and B = [b jk ] n×p be an n × p matrix. Then AB is defined  To determine the (i, k) th element of AB, take the i th row of A and the k th column of B, multiply the corresponding elements, and add the result  Multiply corresponding elements as in Figure 4.1 Figure 4.1

Discrete Mathematical Structures: Theory and Applications 58

Discrete Mathematical Structures: Theory and Applications 59 Matrices Note that the dimensions of AB are m x p. Then (AB) x C is defined and has dimensions m x q Convince yourself that A x (BC) is defined and also has dimensions m x q

Discrete Mathematical Structures: Theory and Applications 60

Discrete Mathematical Structures: Theory and Applications 61 Matrices – Matrix transpose  The rows of A are the columns of A T and the columns of A are the rows of A T

Discrete Mathematical Structures: Theory and Applications 62 Matrices - Symmetric

Discrete Mathematical Structures: Theory and Applications 63 Matrices  Boolean (Zero-One) Matrices  Matrices whose entries are 0 or 1  Allows for representation of matrices in a convenient way in computer memory and for the design and implementation of algorithms to determine the transitive closure of a relation

Discrete Mathematical Structures: Theory and Applications 64 Matrices  Boolean (Zero-One) Matrices  The set {0, 1} is a lattice under the usual “less than or equal to” relation, where for all a, b ∈ {0, 1}, a ∨ b = max{a, b} and a ∧ b = min{a, b}

Discrete Mathematical Structures: Theory and Applications 65 Matrices – Logical Operations Note: join is the OR operation; meet is the AND operation

Discrete Mathematical Structures: Theory and Applications 66 Matrices

Discrete Mathematical Structures: Theory and Applications 67 Matrices – Boolean Product

Discrete Mathematical Structures: Theory and Applications 68

Discrete Mathematical Structures: Theory and Applications 69 The Matrix of a Relation and Closure

Discrete Mathematical Structures: Theory and Applications 70 The Matrix of a Relation and Closure

Discrete Mathematical Structures: Theory and Applications 71 The Matrix of a Relation and Closure

Discrete Mathematical Structures: Theory and Applications 72 The Matrix of a Relation and Closure

Discrete Mathematical Structures: Theory and Applications 73

Discrete Mathematical Structures: Theory and Applications 74  ALGORITHM 4.3: Compute the transitive closure  Input: M —Boolean matrices of the relation R n—positive integers such that n × n specifies the size of M  Output: T —an n × n Boolean matrix such that T is the transitive closure of M  1. procedure transitiveClosure(M,T,n)  2. begin  3. A := M;  4. T := M;  5. for i := 2 to n do  6. begin  7. A := //A = M i  8. T := T ∨ A; //T= M ∨ M 2 ∨ · · · ∨ M i  9. end  10. end

Discrete Mathematical Structures: Theory and Applications 75 Warshall’s Algorithm for Determining the Transitive Closure  Previously, the transitive closure of a relation R was found by computing the matrices and then taking the Boolean join  This method is expensive in terms of computer time  Warshall’s algorithm: an efficient algorithm to determine the transitive closure

Discrete Mathematical Structures: Theory and Applications 76 Warshall’s Algorithm for Determining the Transitive Closure  Let A = {a 1, a 2,..., a n } be a finite set, n ≥ 1, and let R be a relation on A.  Warshall’s algorithm determines the transitive closure by constructing a sequence of n Boolean matrices

Discrete Mathematical Structures: Theory and Applications 77 Warshall’s Algorithm for Determining the Transitive Closure

Discrete Mathematical Structures: Theory and Applications 78 Warshall’s Algorithm for Determining the Transitive Closure

Discrete Mathematical Structures: Theory and Applications 79 Warshall’s Algorithm for Determining the Transitive Closure

Discrete Mathematical Structures: Theory and Applications 80 Warshall’s Algorithm for Determining the Transitive Closure  ALGORITHM 4.4: Warshall’s Algorithm  Input: M —Boolean matrices of the relation R  n—positive integers such that n × n specifies the size of M  Output: W —an n × n Boolean matrix such that W is the transitive closure of M  1. procedure WarshallAlgorithm(M,W,n)  2. begin  3. W := M;  4. for k := 1 to n do  5. for i := 1 to n do  6. for j := 1 to n do  7. if W[i,j] = 1 then  8. if W[i,k] = 1 and W[k,j] = 1 then  9. W[i,j] := 1;  10. end

Discrete Mathematical Structures: Theory and Applications 81

Discrete Mathematical Structures: Theory and Applications 82

Discrete Mathematical Structures: Theory and Applications 83 Learning Objectives  Learn the basic counting principles— multiplication and addition  Explore the pigeonhole principle  Learn about permutations  Learn about combinations

Discrete Mathematical Structures: Theory and Applications 84 Basic Counting Principles

Discrete Mathematical Structures: Theory and Applications 85 Basic Counting Principles

Discrete Mathematical Structures: Theory and Applications 86 Basic Counting Principles  There are three boxes containing books. The first box contains 15 mathematics books by different authors, the second box contains 12 chemistry books by different authors, and the third box contains 10 computer science books by different authors.  A student wants to take a book from one of the three boxes. In how many ways can the student do this?

Discrete Mathematical Structures: Theory and Applications 87 Basic Counting Principles  Suppose tasks T 1, T 2, and T 3 are as follows:  T 1 : Choose a mathematics book.  T 2 : Choose a chemistry book.  T 3 : Choose a computer science book.  Then tasks T 1, T 2, and T 3 can be done in 15, 12, and 10 ways, respectively.  All of these tasks are independent of each other. Hence, the number of ways to do one of these tasks is = 37.

Discrete Mathematical Structures: Theory and Applications 88 Basic Counting Principles

Discrete Mathematical Structures: Theory and Applications 89 Basic Counting Principles  Morgan is a lead actor in a new movie. She needs to shoot a scene in the morning in studio A and an afternoon scene in studio C. She looks at the map and finds that there is no direct route from studio A to studio C. Studio B is located between studios A and C. Morgan’s friends Brad and Jennifer are shooting a movie in studio B. There are three roads, say A 1, A 2, and A 3, from studio A to studio B and four roads, say B 1, B 2, B 3, and B 4, from studio B to studio C. In how many ways can Morgan go from studio A to studio C and have lunch with Brad and Jennifer at Studio B?

Discrete Mathematical Structures: Theory and Applications 90 Basic Counting Principles  There are 3 ways to go from studio A to studio B and 4 ways to go from studio B to studio C.  The number of ways to go from studio A to studio C via studio B is 3 * 4 = 12.

Discrete Mathematical Structures: Theory and Applications 91 Basic Counting Principles

Discrete Mathematical Structures: Theory and Applications 92 Basic Counting Principles  Consider two finite sets, X 1 and X 2. Then  This is called the inclusion-exclusion principle for two finite sets.  Consider three finite sets, A, B, and C. Then  This is called the inclusion-exclusion principle for three finite sets.

Discrete Mathematical Structures: Theory and Applications 93 Pigeonhole Principle  The pigeonhole principle is also known as the Dirichlet drawer principle, or the shoebox principle.

Discrete Mathematical Structures: Theory and Applications 94 Pigeonhole Principle

Discrete Mathematical Structures: Theory and Applications 95

Discrete Mathematical Structures: Theory and Applications 96 Pigeonhole Principle

Discrete Mathematical Structures: Theory and Applications 97 Permutations

Discrete Mathematical Structures: Theory and Applications 98 Permutations

Discrete Mathematical Structures: Theory and Applications 99 Combinations

Discrete Mathematical Structures: Theory and Applications 100 Combinations

Discrete Mathematical Structures: Theory and Applications 101 Generalized Permutations and Combinations

Discrete Mathematical Structures: Theory and Applications 102 Generalized Permutations and Combinations Consider 10 chips of 3 types ( R, W, B) with 5 R, 3 W and 2 B Then, n = 10, k = 3, and n1=5, n2=3 and n3 =2. The number of different arrangements of these 10 chips is: C(10,5) * C(10-5,3) * C(10-5-3,2) = C(10,5) * C(5,3) * C(2,2) = 10! / 5!(5!) * 5!/ 3!(2!) * 2! / 2!(1!) = 10! / 5!3!2! = n!/ n1!n2!n3! = 10 * 9 * 8 * 7 * 6 / (3 * 2 * 1 * 2 * 1) = 5 * 9 * 8 * 7 = 2520

Discrete Mathematical Structures: Theory and Applications 103 Generalized Permutations and Combinations Consider an 8-bit string. How many 8-bit strings contain exactly three 1s ? Using the formula above, with n = 8 and k = 3, the answer is C(8,3). C(8,3) = 8! / 3!(8-3)! = 8!/ 3!5! = 8 * 7 * 6 / 3 * 2 * 1 = 56 Examples: etc

Discrete Mathematical Structures: Theory and Applications 104 Generalized Permutations and Combinations Suppose we have x + y = 3, with x≥ 0, y ≥0. Then n = 3, k=2 and the number of integer solutions is: C(3+2-1,2-1) = C(4,1) = 4 (0,3), (1,2), (2,1), (3,0)

Discrete Mathematical Structures: Theory and Applications 105 Generalized Permutations and Combinations Let objects = {1,2,3,4,5}, n = 5, r=3. Then the number of 3-combinations of these objects ( with repetitions allowed) is C(5-1+3,3) = C(7,3) = 7! / 3!(4!) = , 222, 333, 444, , 113,114, , 223, 224, , 332, 334, , 442, 443, , 552, 553, , 124, 125, 134, 135, , 235, Repeat all 3 = 5 combinations Repeat two of three = 20 combinations No repeats = 10 combinations

Discrete Mathematical Structures: Theory and Applications 106 Permutations and Combinations Permutations and Combinations - Rosen