Title: DISCRETE COMPUTATIONAL STRUCTURES
1DISCRETE COMPUTATIONAL STRUCTURES
2CS 23022 OUTLINE
- Matrices Closures
- Counting Principles
- Discrete Probability
- Congruences
- Recurrence Relations
- Algorithm Complexity
- Graph Theory
- Trees Networks
- Grammars Languages
- Sets
- Logic
- Proof Techniques
- Algorithms
- Integers Induction
- Relations Posets
- Functions
- Boolean Algebra Combinatorial Circuits
3Learning 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
4Two-Element Boolean Algebra
Let B 0, 1.
5Two-Element Boolean Algebra
6(No Transcript)
7(No Transcript)
8(No Transcript)
9Two-Element Boolean Algebra
10Two-Element Boolean Algebra
11(No Transcript)
12Minterm
13(No Transcript)
14Maxterm
15(No Transcript)
16(No Transcript)
17(No Transcript)
18Boolean Algebra
19Boolean Algebra
20Logical Gates and Combinatorial Circuits
21Logical Gates and Combinatorial Circuits
22Logical Gates and Combinatorial Circuits
23Logical Gates and Combinatorial Circuits
24(No Transcript)
25(No Transcript)
26(No Transcript)
27(No Transcript)
28(No Transcript)
29(No Transcript)
30(No Transcript)
31(No Transcript)
32(No Transcript)
33(No Transcript)
34(No Transcript)
35(No Transcript)
36(No Transcript)
37(No Transcript)
38(No Transcript)
39(No Transcript)
40Logical Gates and Combinatorial Circuits
- The Karnaugh map, or K-map for short, can be used
to minimize a sum-of-product Boolean expression.
41(No Transcript)
42(No Transcript)
43(No Transcript)
44CS 23022 OUTLINE
- Matrices Closures
- Congruences
- Counting Principles
- Discrete Probability
- Recurrence Relations
- Algorithm Complexity
- Graph Theory
- Trees Networks
- Grammars Languages
- Sets
- Logic
- Proof Techniques
- Algorithms
- Integers Induction
- Relations Posets
- Functions
- Boolean Algebra Combinatorial Circuits
45Learning 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
Warshalls algorithm
46Matrices
47Matrices
48Matrices terms equal , square
49Matrices- terms zero matrix, diagonal elements
50Matrices- terms diagonal matrix, identity matrix
51Matrices 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
52Matrices Matrix Addition Example
53Matrices- Multiply a Constant x Matrix
54Matrices Matrix Difference
55Matrices - 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)
56Matrices
- 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
57Matrices
Figure 4.1
- Let A aijmn be an m n matrix and B bjk
np be an n p matrix. Then AB is defined - To determine the (i, k)th element of AB, take the
ith row of A and the kth column of B, multiply
the corresponding elements, and add the result - Multiply corresponding elements as in Figure 4.1
58(No Transcript)
59Matrices
Note that the dimensions of AB are m x p.Then
(AB) x C is defined and has dimensions m x
qConvince yourself that A x (BC) is defined and
also has dimensions m x q
60(No Transcript)
61Matrices Matrix transpose
- The rows of A are the columns of AT and the
columns of A are the rows of AT
62Matrices - Symmetric
63Matrices
- 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
64Matrices
- 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 maxa, b and a ? b mina, b
65Matrices Logical Operations
Note join is the OR operation meet is the AND
operation
66Matrices
67Matrices Boolean Product
68(No Transcript)
69The Matrix of a Relation and Closure
70The Matrix of a Relation and Closure
71The Matrix of a Relation and Closure
72The Matrix of a Relation and Closure
73(No Transcript)
74- ALGORITHM 4.3 Compute the transitive closure
- Input M Boolean matrices of the relation R
npositive 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 Mi
- 8. T T ? A //T M ? M2 ?
? Mi - 9. end
- 10. end
75Warshalls 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 - Warshalls algorithm an efficient algorithm to
determine the transitive closure
76Warshalls Algorithm for Determining the
Transitive Closure
- Let A a1, a2, . . . , an be a finite set, n
1, and let R be a relation on A. - Warshalls algorithm determines the transitive
closure by constructing a sequence of n Boolean
matrices
77Warshalls Algorithm for Determining the
Transitive Closure
78Warshalls Algorithm for Determining the
Transitive Closure
79Warshalls Algorithm for Determining the
Transitive Closure
80Warshalls Algorithm for Determining the
Transitive Closure
- ALGORITHM 4.4 Warshalls Algorithm
- Input M Boolean matrices of the relation R
- npositive 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 Wi,j 1 then
- 8. if Wi,k 1 and Wk,j
1 then - 9. Wi,j 1
- 10. end
81(No Transcript)
82(No Transcript)
83Learning Objectives
- Learn the basic counting principlesmultiplication
and addition - Explore the pigeonhole principle
- Learn about permutations
- Learn about combinations
84Basic Counting Principles
85Basic Counting Principles
86Basic 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?
87Basic Counting Principles
- Suppose tasks T1, T2, and T3 are as follows
- T1 Choose a mathematics book.
- T2 Choose a chemistry book.
- T3 Choose a computer science book.
- Then tasks T1, T2, and T3 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 15 12 10 37.
88Basic Counting Principles
89Basic 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. Morgans friends Brad and
Jennifer are shooting a movie in studio B. There
are three roads, say A1, A2, and A3, from studio
A to studio B and four roads, say B1, B2, B3, and
B4, 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?
90Basic 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.
91Basic Counting Principles
92Basic Counting Principles
- Consider two finite sets, X1 and X2. 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.
93Pigeonhole Principle
- The pigeonhole principle is also known as the
Dirichlet drawer principle, or the shoebox
principle.
94Pigeonhole Principle
95(No Transcript)
96Pigeonhole Principle
97Permutations
98Permutations
99Combinations
100Combinations
101Generalized Permutations and Combinations
102Generalized 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 n15, n23 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
103Generalized 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 11100000
00000111 00011100 01010100 etc
104Generalized Permutations and Combinations
Suppose we have x y 3, with x 0, y 0. Then
n 3, k2 and the number of integer solutions
is C(32-1,2-1) C(4,1) 4 (0,3) , (1,2),
(2,1) , (3,0)
105Generalized Permutations and Combinations
Let objects 1,2,3,4,5, n 5, r3. Then the
number of 3-combinations of these objects ( with
repetitions allowed) is C(5-13,3) C(7,3) 7!
/ 3!(4!) 35
111, 222, 333, 444, 555 112, 113,114, 115 221,
223, 224 , 225 331, 332, 334, 335 441, 442, 443,
445 551, 552, 553, 554 123, 124, 125 , 134,
135,145 234, 235, 245 345
Repeat all 3 5 combinations Repeat two of
three 20 combinations No repeats 10
combinations
106Permutations and Combinations
- Permutations and Combinations - Rosen