106
DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Embed Size (px)

Citation preview

Page 1: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

DISCRETE COMPUTATIONAL STRUCTURES

CS 23022

Fall 2005

Page 2: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

CS 23022 OUTLINE9. 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

Page 3: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

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

Page 4: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 4

Two-Element Boolean AlgebraLet B = {0, 1}.

Page 5: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 5

Two-Element Boolean Algebra

Page 6: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 6

Page 7: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 7

Page 8: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 8

Page 9: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 9

Two-Element Boolean Algebra

Page 10: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 10

Two-Element Boolean Algebra

Page 11: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 11

Page 12: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 12

Minterm

Page 13: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 13

Page 14: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 14

Maxterm

Page 15: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 15

Page 16: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 16

Page 17: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 17

Page 18: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 18

Boolean Algebra

Page 19: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 19

Boolean Algebra

Page 20: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 20

Logical Gates and Combinatorial Circuits

Page 21: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 21

Logical Gates and Combinatorial Circuits

Page 22: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 22

Logical Gates and Combinatorial Circuits

Page 23: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 23

Logical Gates and Combinatorial Circuits

Page 24: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 24

Page 25: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 25

Page 26: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 26

Page 27: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 27

Page 28: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 28

Page 29: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 29

Page 30: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 30

Page 31: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 31

Page 32: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 32

Page 33: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 33

Page 34: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 34

Page 35: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 35

Page 36: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 36

Page 37: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 37

Page 38: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 38

Page 39: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 39

Page 40: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

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.

Page 41: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 41

Page 42: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 42

Page 43: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 43

Page 44: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

CS 23022 OUTLINE9. Matrices & Closures10. 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

Page 45: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

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

Page 46: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 46

Matrices

Page 47: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 47

Matrices

Page 48: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 48

Matrices – terms : equal , square

Page 49: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 49

Matrices- terms: zero matrix, diagonal elements

Page 50: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 50

Matrices- terms: diagonal matrix, identity matrix

Page 51: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

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

Page 52: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 52

Matrices – Matrix Addition Example

Page 53: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 53

Matrices- Multiply a Constant x Matrix

Page 54: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 54

Matrices – Matrix Difference

Page 55: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

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)

Page 56: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

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

Page 57: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 57

Matrices

Let A = [aij]m×n be an m × n matrix and B = [bjk ]n×p 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

Figure 4.1

Page 58: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 58

Page 59: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

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 qConvince yourself that A x (BC) is defined and also has dimensions m x q

Page 60: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 60

Page 61: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 61

Matrices – Matrix transpose

The rows of A are the columns of AT and the columns of A are the rows of AT

Page 62: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 62

Matrices - Symmetric

Page 63: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

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

Page 64: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

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}

Page 65: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 65

Matrices – Logical Operations

Note: join is the OR operation; meet is the AND operation

Page 66: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 66

Matrices

Page 67: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 67

Matrices – Boolean Product

Page 68: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 68

Page 69: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 69

The Matrix of a Relation and Closure

Page 70: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 70

The Matrix of a Relation and Closure

Page 71: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 71

The Matrix of a Relation and Closure

Page 72: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 72

The Matrix of a Relation and Closure

Page 73: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 73

Page 74: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

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 = Mi

8. T := T ∨ A; //T= M ∨ M2 ∨ · · · ∨ Mi

9. end 10. end

Page 75: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

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

nRM

Page 76: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 76

Warshall’s 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.

Warshall’s algorithm determines the transitive closure by constructing a sequence of n Boolean matrices

Page 77: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 77

Warshall’s Algorithm for Determining the Transitive Closure

Page 78: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 78

Warshall’s Algorithm for Determining the Transitive Closure

Page 79: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 79

Warshall’s Algorithm for Determining the Transitive Closure

Page 80: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

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

Page 81: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 81

Page 82: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 82

Page 83: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

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

Page 84: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 84

Basic Counting Principles

Page 85: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 85

Basic Counting Principles

Page 86: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

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?

Page 87: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 87

Basic 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.

Page 88: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 88

Basic Counting Principles

Page 89: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

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 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?

Page 90: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

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.

Page 91: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 91

Basic Counting Principles

Page 92: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 92

Basic 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.

Page 93: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 93

Pigeonhole Principle

The pigeonhole principle is also known as the Dirichlet drawer principle, or the shoebox principle.

Page 94: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 94

Pigeonhole Principle

Page 95: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 95

Page 96: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 96

Pigeonhole Principle

Page 97: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 97

Permutations

Page 98: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 98

Permutations

Page 99: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 99

Combinations

Page 100: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 100

Combinations

Page 101: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 101

Generalized Permutations and Combinations

Page 102: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

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

Page 103: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

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: 11100000 00000111 00011100 01010100 etc

Page 104: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

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)

y = 3 - x

0, 3

1, 2

2, 1

3, 000.5

11.5

22.5

33.5

0 1 2 3 4

x

y

Page 105: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

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!) = 35

111, 222, 333, 444, 555

112, 113,114, 115221, 223, 224 , 225331, 332, 334, 335441, 442, 443, 445551, 552, 553, 554

123, 124, 125 , 134, 135,145234, 235, 245345

Repeat all 3 = 5 combinations

Repeat two of three = 20 combinations

No repeats = 10 combinations

Page 106: DISCRETE COMPUTATIONAL STRUCTURES CS 23022 Fall 2005

Discrete Mathematical Structures: Theory and Applications 106

Permutations and Combinations

Permutations and Combinations - Rosen