39
College of Computer Studies 1 MELJUN P. CORTES, MBA,MPA Course Title: DISCRETE STRUCTURES I Course Description: The course introduces the students to mathematical logic: propositions qualifiers, predicates, proof, techniques; mathematical induction; Fundamentals of set theory: sets, power sets, algebra of sets, relations, functions, accountability and finiteness; graphs and trees. Course Objectives: At the end of the term, the students should be able to: a. To apply the theories and operations on sets. b. To understand and appreciate the use of combinations and progression for practical application. c. To understand and apply relations, digraphs, and functions by way of problems applicable to computer applications. PRELIM PERIOD SETS It is any well-defined collection of objects. It is a collection of distinct objects, without repetition and without ordering Set Notation: Denoted by capital letter. Example: A = {, , 0} C = {1, 2, 3} B = {a, b, c, d} D = {Pascal, C, Cobol} Methods In Describing a Set: 1. Listing Method – Roster / Tabular Form It is listing or enumerating all the elements of a given set. Example: A = {a, b, c} 2. Rule Method – Set-Builder Form The elements have properties in common. The elements must satisfy a given rule or condition. Example: A = { x | x is a positive integer < 4} A = { x | x < 5}

MELJUN CORTES Instructional Manual Multimedia

Embed Size (px)

DESCRIPTION

MELJUN CORTES Instructional Manual Multimedia

Citation preview

Page 1: MELJUN CORTES Instructional Manual Multimedia

College of Computer Studies

1

MELJUN P. CORTES, MBA,MPA Course Title: DISCRETE STRUCTURES I Course Description:

The course introduces the students to mathematical logic: propositions qualifiers,

predicates, proof, techniques; mathematical induction; Fundamentals of set theory: sets, power sets, algebra of sets, relations, functions, accountability and finiteness; graphs and trees.

Course Objectives:

At the end of the term, the students should be able to:

a. To apply the theories and operations on sets. b. To understand and appreciate the use of combinations and

progression for practical application.

c. To understand and apply relations, digraphs, and functions by way of problems applicable to computer applications.

PRELIM PERIOD

SETS It is any well-defined collection of objects.

It is a collection of distinct objects, without repetition and without ordering Set Notation: Denoted by capital letter. Example:

A = {, , 0} C = {1, 2, 3} B = {a, b, c, d} D = {Pascal, C, Cobol} Methods In Describing a Set:

1. Listing Method – Roster / Tabular Form It is listing or enumerating all the elements of a given set. Example: A = {a, b, c}

2. Rule Method – Set-Builder Form

The elements have properties in common. The elements must satisfy a given rule or condition. Example: A = { x | x is a positive integer < 4} A = { x | x < 5}

Page 2: MELJUN CORTES Instructional Manual Multimedia

College of Computer Studies

2

MELJUN P. CORTES, MBA,MPA Element It is a member of a given set or an object in the collection Element Notation: Denoted by small letter/s. Example:

A = {a, b, c} where: a A ; b A ; c A ; d A Types of Set

1. Finite – elements can be counted. Example: A = {a, b, c}

2. Infinite – elements cannot be counted. Example: A = { x | x is a positive integer}

Things to remember in listing elements:

1. Order of elements is not important 2. Repetition must be ignored

Subset ( ) If A is a subset of B, A is contained in B or every element of A is in B.

Example: A = {a, b} B = {a, b, c}

A B but B A Note:

1. Every set is a subset of itself 2. An empty set is a subset of every set.

3. If A B then there is at least one element in A that is not in B.

Example: A = {1, 2, 3 } The subsets of A are: P(A) = { {1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}, {1, 2, 3}, { } } To check:

|A| = 2n = 23 = 8

Page 3: MELJUN CORTES Instructional Manual Multimedia

College of Computer Studies

3

MELJUN P. CORTES, MBA,MPA

Proper Subset ()

A is a proper sunset of B if A B and A B

Cardinality of the set ( | | ) It is the total number of elements in a given set

Example: A = {1, 2, 3 } | A | = 3

Empty Set / Null or Void Set It is a set containing no element

Example: A = { } or A =

If A = {}, A is not an empty set

Singleton

a set containing only one element Example: A = { 1 }

Comparable Set At least one set is a subset of another set

Conditions so that A & B are comparable:

1. A B & B A Example: A = {1, 2, 3, 4}

B = {4, 3, 2, 1}

2. A B & B A Example: A= {1, 2 } B = {1, 2, 3}

3. A B & B A A= {a, b, c} B= {a, b}

Non-Comparable Set

No set is a subset of the other set. ( A B & B A & A B)

Example: A = {1, 2, 3}

Page 4: MELJUN CORTES Instructional Manual Multimedia

College of Computer Studies

4

MELJUN P. CORTES, MBA,MPA B = {4, 5, 6}

Equal Set It is a set having exactly the same cardinality and kind of elements.

Example: A = {1, 2, 3} B = {1, 2, 3}

Equivalent Set

It is a set having the same cardinality.

Example: A = {1, 2, 3} B = {4, 5, 6}

One-to-one correspondence Every element of A is associated or paired to every element in B.

Example: A = {1, 2, 3} B = {4, 5, 6}

Disjoint Set

The sets having no common elements Example: A = {1, 4, 5} B = {3, 2, 6}

Universal Set or Set of all Sets

It is the biggest set under investigation wherein the other sets are subsets of the given set.

Example: U = {1, 2, 3, 4, 5, 6} * NO REPETITION A = {1, 2, 3} B = {4, 5, 6} C = {5, 6}

Set of Sets, Family of Sets, Class of Sets It is a collection of set All the elements of the given set are sets.

Example: A = {A, B, C} A = {{1, 2, 3}, {4, 5, 6}, {5, 6}}

B = {A, B, C, D, 0, 2} C = {A, B, C, D, z}

Page 5: MELJUN CORTES Instructional Manual Multimedia

College of Computer Studies

5

MELJUN P. CORTES, MBA,MPA

A Complement with Respect to: Ā, A', AC U – new set of elements that belong to U but not in A ( with respect to U )

Example: U = {1, 2, 3, 4, 5, 6} A = {1, 2, 3}

A’ = {4, 5, 6} B – new sets of elements that belong to B but not in A (with respect to B)

Example: B = {a, b, c, d, e} A = {a, b, c} A’ = {d, e}

Power Set (P (A))

It is a family of all subsets of a given set It is the set of all subsets

Example: A = {1, 2, 3} P(A) = { {1}, {2}, {3}, {1,2}, {2, 3}, {1,3}, { }, {1, 2, 3} }

To check: P(A) = 2n

= 23 = 8

BASIC SET OPERATIONS

1. Union (A B) It is a new set of elements that belong to A or B or to both A and B. Example: A = {1, 2, 3, 4}

B = {2, 4, 6, 7}

A B = {1, 2, 3, 4, 5, 6, 7}

2. Intersection (A D) It is a new sets of elements that belong to A but not to B. Example: A = {1, 2, 3, 4}

B = {2, 4, 6, 7}

A B = {2, 4} 3. Difference (A – B, A / B, A ~ B) It is a new sets of elements that belong to A but not to B.

Example: A = {1, 2, 3, 4} B = {1, 2, 4, 6, 7} A – B = {3, 5}

B – A = {6, 7} 4. Complement (A’, AC, A, Ā complement) it is a new set of elements that belong to U but not to A.

Example: U = {1, 2, 3, 4, 5, 6, 7, 8, 9} A = {1, 2, 3, 4} B = {2, 4, 6}

A’ = {5, 6, 7, 8, 9} B’ = {1, 3, 5, 7, 8, 9}

Page 6: MELJUN CORTES Instructional Manual Multimedia

College of Computer Studies

6

MELJUN P. CORTES, MBA,MPA

5. Symmetrical Difference (A B ) new set of elements that belong to A or B but not to A and B

Example: A = {1, 2, 3, 4, 5} B = {0, 1, 2, 6, 7, 8}

A B = {0, 3, 4, 5, 6, 7, 8} ALGEBRAIC PROPERTIES OF SET OPERATIONS

1.) Commutative Properties

a. A B = B A

b. A B = B A

2.) Associative Properties

a. A (B C) = (A B) C

b. A (B C) = (A B) C

3.) Distributive Properties

a. A (B C) = (A B) (A C)

b. A (B C) = (A B) (A C)

4.) Idempotent Properties

a. A A = A

b. A A = A

5.) Properties of a Null Set

a. A =

b. A = A

6.) Properties of a Universal Set

a. A U = U

b. A U = A

7.) Properties of A Complement a. A = A involution

b. A A’ = U

c. A A’ =

d. ’ = U

e. U’ = _ _

f. A B = A B

g. A B = A B

Page 7: MELJUN CORTES Instructional Manual Multimedia

College of Computer Studies

7

MELJUN P. CORTES, MBA,MPA Proving: 1. Let: U = {1, 2, 3, 4, 5, 6} A = {1, 3, 5} B = {2, 4, 6} C = {4, 5} De Morgans’s Law _____ _ _

1. A B = A B

{1, 2, 3, 4, 5, 6} = {2, 4, 6} {1, 3, 5} {1, 2, 3, 4, 5, 6} = {1, 2, 3, 4, 5, 6}

_____ _ _

2. A B = A B

{ } = {2, 4, 6} {1, 3, 5} { } = { }

2. Let: U = {a, b, c, d, e, f} A = {a, b, c} B = {c, d, e, f}

1) A A’ = U

{a, b, c} {d, e, f} = {a, b, c, d, e, f} {a, b, c, d, e, f} = {a, b, c, d, e, f}

Venn Diagram It represents relation and operator using the plane geometrical figures such as rectangle, circle, ellipse.

A B A B A B A B

A

A

B

Page 8: MELJUN CORTES Instructional Manual Multimedia

College of Computer Studies

8

MELJUN P. CORTES, MBA,MPA

A B A B

A – B A B

Set Relations

1. C B

2. A ≠ B

3. B A

4. B ≠ C

5. A ≠ C

6. C ≠ B

7. C A

8. A B 9. A and B are not compatible 10. A and B are not disjoint 11. A and C are disjoint 12. B and C are not disjoint

13. A, B, C U

A

B

C

Page 9: MELJUN CORTES Instructional Manual Multimedia

College of Computer Studies

9

MELJUN P. CORTES, MBA,MPA LINE DIAGRAM

1. A B 2. A B C C

A B B A ADDITION PRINCIPLE

1. Two Sets Addition a) Disjoint

| A B | = | A | + | B | b) Not disjoint

| A B | = | A | + | B | - | A B |

Note: | A B | is subtracted from | A | + | B | to avoid duplication because

A B belongs to both sets and the sum | A | + | B | includes the numbers of elements twice.

Example:

A computer company must hire 25 programmers to handle systems programming tasks and 40 programmers for application programming. Of those hired, 10 will be expected to perform task of each type. How many programmers must be hired? Given: | A | = 25 | B | = 40

| A B | = 10 Solution:

| A B |= | A | + | B | - | A B | = 25 + 40 – 10 = 55 programmers

B

A

B

A

C

Page 10: MELJUN CORTES Instructional Manual Multimedia

College of Computer Studies

10

MELJUN P. CORTES, MBA,MPA

A 5

B 5

10 15 C 70

2. Three Sets Addition

| A U B U C | = | A | + | B | + | C | - | A B | - | A C| - | A C | + |A B C | Example #1: A survey is taken on methods of commuter travel. Each respondent is to check bus, train or automobile as a major method of traveling to work. More than one answer is permitted. The result were as follows: | A | = 30 people checked bus | B | = 35 people checked train | C | = 100 people checked automobile

| A B | = 15 checked bus and train

| A C | = 15 checked bus and automobile

| B C | = 20 checked train and automobile

| A B C | = 5 checked all three methods Questions:

a.) How many respondents completed the survey? b.) How many checked exactly one of the three methods of commuter travel? c.) Draw the Venn diagram.

Answer:

a.) | A U B U C | = | A | + | B | + | C | - | A B | - | B C | - | A C| + | A B C | = 30 + 35 + 100 – 15 – 20 – 15 +5

= 120

b.) | A B | = 15 – 5 = 10 | A | = 30 – 10 – 10 – 5 – 5 = 5

| B C | = 20 – 5 = 15 | B | = 35 – 10 – 15 – 5 = 5

| A C | = 15 – 5 = 10 | C | = 100 – 15 – 10 – 5 = 70 -------------

80 respondents c.) Venn Diagram

10

5

Page 11: MELJUN CORTES Instructional Manual Multimedia

College of Computer Studies

11

MELJUN P. CORTES, MBA,MPA

A 28

B 18

12 7 C 10

Example #2:

Suppose that 100 CS students take at least one of the languages BASIC, COBOL, PASCAL.

| A | = 65 study BASIC | A B | = 20 study BASIC and COBOL

| B | = 42 study COBOL | A C | = 25 study BASIC and PASCAL

| C | = 42 study PASCAL | B C | = 15 study COBOL and PASCAL Questions:

a. Find the number of students who study all of the languages. b. Find the number of students who study exactly one of the languages. c. Draw the Venn diagram representation.

Answer:

a. | A U B U C | = | A | + |B | + | C | - | A B | - | B C | - | A C | + | A B C | 100 = 65+45+42-20-15+x 100 = 150 – 60 = x x = 150 – 60 – 152 x = 8

b. | A B | = 20 – 8 = 12

| A C | = 25 – 8 = 14

| B C | = 15 – 8 = 7 | A | = 65 – 12 – 17 – 8 = 28 | B | = 45 – 12 – 7 – 8 = 18 | C | = 42 – 17 – 7 – 8 = 10 20

c. Venn Diagram

12

5

Page 12: MELJUN CORTES Instructional Manual Multimedia

College of Computer Studies

12

MELJUN P. CORTES, MBA,MPA COMBINATORICS Product Set

A. Involving 2 Sets (A X B)

The product set of A and B consist of ordered pair (a, b) where at a A

and b B, denoted by A X B (A cross B) It is also called the Cartesian Product of A and B

A X B = {(a, b) | a A, b B} Note:

1. A X B = {a, b} elements

2. A X B ≠ B X A not commutative unless A = B or one of the sets is

empty

3. A X A = A2

Example: A = {1, 2, 3} B = {a, b} A X B = {(1, a), (1, b), (2, a), (2, b), (3, a), (3, b)} B X A = {(a, 1), (a, 2), (a, 3), (b, 1), (b, 2), (b, 3)} A X A = {(1, 1), (1, 2), (1, 3), (2, 1), (2, 2), (2, 3), (3, 1), (3, 2), (3, 3)}

B. Involving 3 Sets (A X B X C)

Where a A, b B, c C Example: A = {a, b} B = {1, 2, 3} C = {x, y} A X B X C = {(a, 1, x), (a, 1, y), (a, 2, x), (a, 2, y), (a, 3, x), (a, 3, y), (b, 1, x), (b, 1, y), (b, 2, x), (b, 2, y), (b, 3, x), (b, 3, y)} Tree Diagram 1 x (a, 1, x) y (a, 1, y) a 2 x (a, 2, x) y (a, 2, y) 3 x (a, 3, x) y (a, 3, y) 1 x (b, 1, x) y (b, 1, y) b 2 x (b, 2, x) y (b, 2, y)

3 x (b, 3, x)

Page 13: MELJUN CORTES Instructional Manual Multimedia

College of Computer Studies

13

MELJUN P. CORTES, MBA,MPA y (b, 3, y)

EVENT it is any happening or occurrence. SUCCESSIVE EVENTS it is an occurrence, which can happen one after the other SIMULTANEOUS EVENTS these are events, which can happen at the same time FUNDAMENTAL PRINCIPLES OF COUNTING a. Sum Rule It is the whole is the sum of its parts If the events can occur in m ways and another event can occur in n ways, then there are m + n ways in which one of these two events can happen It is a successive event The keyword is OR Example: In how many 2-digit or 3-digit numbers can be performed using the digits 1, 2, 3, 4, 5, 6, 8 and 9.

a. With repetition B1 = 7.7 = 49 B2 = 7.7.7 = 343 -------------------------- 392 ways

b. Without repetition B1 = 7.6 = 42 B2 = 7.6.5 = 210 ------------------------- 252 ways

b. Product Rule If one event can occur in m ways and another event can happen in n ways, then there is m x n ways in which these two events can occur together simultaneously. The keyword is AND Example: In how many ways can one order a bottle of soft drinks and a sandwich if the canteen offers 8 different soft drinks and 7 different sandwiches? 8 x 7 = 56 ways

Page 14: MELJUN CORTES Instructional Manual Multimedia

College of Computer Studies

14

MELJUN P. CORTES, MBA,MPA c. Combination of Sum Rule and Product Rule Example: How many different license plates are there that includes 1, 2, or 3 letters followed by 4 digits?

a. With repetition E1 = 26.10.10.10.10 260,000 E2 = 26.26.10.10.10.10 6,769,000 E3 = 26.26.26.10.10.10.10 175,760,000 182,780,000 ways

b. without repetition E1 = 26.10.9.8.7 131,040 E2 = 26.25.10.9.8.7 3,276,000 E3 = 26.25.24.10.9.8.7 78,624,000 82,031,040 ways FACTORIAL NOTATION Factorial It is the product of all integers from 1 to n n! ( n factorial ) It is the product of all positive integers from 1 to n inclusive when n is a positive integer. Methods:

1. forward 5! = 1.2.3.4.5 2. backward 5! = 5.4.3.2.1

PERMUTATION it is an arrangement of objects in a given order ABC, ACB, BAC, BCCCA, CAB, CBA CASES of PERMUTATION I. Linear Permutation – nPn, P(n,n), nPr, P(n,r) A. Number if permutations of n distinct objects taken all a time Formula: nPn = n! Examples: 1. In how many ways can 8 teaching assistants be assigned to 8 sections? n = 8 8P8 = 8! = 8.7.6.5.4.3.2.1 = 40,320 ways

Page 15: MELJUN CORTES Instructional Manual Multimedia

College of Computer Studies

15

MELJUN P. CORTES, MBA,MPA 2. Find the number of permutations of the word FROM taken at all times. n = 4 4P4 = 4! = 4.3.2.1 24 ways B. Number of permutation of n distinct objects taken r at a time

Formula: nPr = n! ------ (n - r)!

Examples: 1. Find the number of permutation of 6 distinct objects taken 3 at a time.

n = 6 r = 3 6P3 = 6! 6.5.4.3! -------- = -------------- = 120 ways (6 - 3)!= 3!

2. Find the number of permutation of the word FROM taken 2 at a time. n = 4 r = 2 4P2 = 4! 4.3.2! ------ = ------------ 12 ways (4 - 2)! 2!

C . Number of Permutations with repetition. It is the number of distinct permutation of n distinct objects where n1 is one kind,

n2 is another kind, n3 is the third kind, nk is the kth kind.

Formula: nP (n1, n2, n3, … nk) = n! ----------------- n1! N2! N3! Nk! Example: Find the number of permutation of the word DADDY. n1 D = 3 5P(3,1,1) = 5! 5.4.3!

n2 A = 1 -------------- = ---------------- = 20

n3 Y = 1 3!2!1! 3!

n = 5

Page 16: MELJUN CORTES Instructional Manual Multimedia

College of Computer Studies

16

MELJUN P. CORTES, MBA,MPA II. Circular Permutation It is an ordered arrangement of things in a circular manner or in a ring. Formula: n-1Pn-1 = ( n-1 )!

Example: In how many ways can 4 people be seated at a round table? 4-1P4-1 = (4-1)!

= 3! = 6 COMBINATION It is choosing or selecting of objects without regard of order.

nCr, C(n,r), ( n ), Crn

A. Number of combinations taken r at a time Formula: nCr = n! --------------- r! (n-r)! Examples: 1. In how many ways can a student answer 9 out of 10 questions in an examination? n=10 r=9 nCr = 10! 10!9! ------------------ = -------------- = 10 ways 9!(10-9)! 9!1! 2. In how many committees can 2 chemists and 3 biologists be formed from 5 chemists and 6 biologists? = 5C2 = 6C3 5! 6! = ---------------- x ----------------- 2!(3)! 3!(2!) = 5.4.3! 6.5.4.3! -------------------------- x -------------------------- 2! 3! 3! 2! = 10 x 20 = 200 ways

Page 17: MELJUN CORTES Instructional Manual Multimedia

College of Computer Studies

17

MELJUN P. CORTES, MBA,MPA B. Combination taken in a series The total number of permutations of n things taken at a time Formula: C1 + nC2 + nC3 … + nCn Example: In how many ways can one or more than 5 people enter a room?

= 2n – 1 = 5C1 + 5C2 + 5C3 + 5C4 + 5C5

= 25 – 1 or = 5 + 10 + 10 + 5 + 1 = 31 ways = 31 ways

PRELIM EXAMINATION

MIDTERM PERIOD

MATHEMATICAL PROGRESSION Sequence It is a set of numbers arranged in a definite order Example: 1,2,3,4,5

a. Indefinite sequence sequence associated with it is infinite. b. Finite sequence sequence associated with it is finite.

Term It is every element of the sequence Series It is indicated sum of the sequence. Replace the commas of the sequence with a plus sign(+). TYPE OF PROGRESSION A. Arithmetic Progression ( AP) It is a sequence of the numbers called terms, each of which after the first derived from the preceding one by adding to it a fixed number called common difference (d), which can be found by subtracting any term from the one following it.

Elements of Arithmetic Progression

a or a1 - first term

l or an - last term d - common difference n - number of terms s - sum of all terms

Page 18: MELJUN CORTES Instructional Manual Multimedia

College of Computer Studies

18

MELJUN P. CORTES, MBA,MPA

Formulas: l = a1 + (n-1)d

n n S = ----------- (a1 + l ) or S = ----------- [2a1 + (n-1)d] 2 2

Examples: 1. Write the 1st 6 terms of AP if a) a = 15 d = -2 15, 13, 11, 9, 7, 5 b) a = -20 d = 4 -20, -16, -12, -8, -4, 0

2. Find the value of k

a) 15, 11, k k = 7 b) 28, 23, k k = 18 c) 17, k, 23 k = 20 Arithmetic Mean (AM) terms between the first and the last term of a AP. Example:

Find the AM between a = 2, d = 2, l = 10.

2, 4, 6, 8, 10

Sum of all terms Example: Find the sum of AP if 1, 3, 5, … a8 is given.

S = n/2 [2a + (n-1)d] = 8/2 [2(1) + (8-1)2] = 4(2 + 14) = 64

Page 19: MELJUN CORTES Instructional Manual Multimedia

College of Computer Studies

19

MELJUN P. CORTES, MBA,MPA B. Geometric Progression (GP) It is a sequence of numbers called terms, each of which after the first, is derived from the preceding one by multiplying to it a fixed number called the common ratio (r) which canbe found by dividing any term from the one following it. Elements of Geometric Progression a or a1 - first term

l or an - last term

r - common ration n - number of terms s - sum of all terms

Formulas: l = arn-1 S = a - rl ----------- 1 – r Geometric Series It is the sum of all terms of a given GP. Geometric Means It is the terms between the first term and the last term. Examples: 1. Give the complete GP if a1 = 2, r = 2 up to 6 terms. 2, 4, 8, 16, 32, 64 2. Find the 2 GM between 4 and 32. Find S. 4, 8, 16, 32

l = arn-1 S = a – rl

32 = 4r3 1 – r

r3 = 32 / 4 = 4 – 2(32)

r3 = 8 1 – 2 r = 2 S = 60 C. Harmonic Progression (HP) The sequence of numbers whose reciprocal forms an AP. Example: 1/5, 1/7, 1/9 Harmonic Mean (HM) It is the reciprocals of the AM of the reciprocals of the values under observation.

Page 20: MELJUN CORTES Instructional Manual Multimedia

College of Computer Studies

20

MELJUN P. CORTES, MBA,MPA Example: Insert 2 HM between 1/5 and 1/14 5, 8, 11, 14 l = a + (n-1)d 14 = 5 + (4-1)d 14 = 5 + 3d 9 = 3d d = 3 1/5, 1/8, 1/11, 1/14

RELATIONS AND DIGRAPHS Relations (R)

Let A, B be non-empty sets and let A X B (need A cross B) be defined as A X B = {(a,b) | a is in A and b is in B}, that is A X B, the cartesian product of A and B, is the set of ordered pairs (a,b) such that the first element of the ordered pair a is in A and the second element of the ordered pair b is from. Elements of Relation 1. Set A (non empty set) 2. Set B (non empty set) 3. P(x,y) or P(a,b) - open sentence where P(a,b) is true or false for any ordered pair (a,b) belong to A X B. - It defines the relation of A to B. Relation on A It is a relation of A into itself, that is, a subset of A X A. Example: A = {1, 2, 3} Relation on A = {(1, 1), (1, 2), (1, 3)} Open sentence – P(x,y) or P(a,b) 1. P(a,b) is true – a R b

a R b is related to b Example: Let R = {R,’R’, P(x,y)} where R is a set of real numbers and P(x,y) reas “x is less than

y” P(5,10) = T 5 R 10

Page 21: MELJUN CORTES Instructional Manual Multimedia

College of Computer Studies

21

MELJUN P. CORTES, MBA,MPA 2. P(a, b) is false – A R b a is not related to b Example: Let R = {R, ‘R’, P(x,y)} where R’ is a set of real numbers and P(x,y) reads “x is less than y”, that is “a is less than b” P(10,5) = F 10 R 5 Binary Relation from A to b A relation that is a subject of A X B, the first coordinates is from A, the second coordinates is from B. Relation from A to B is a subset of A X B. Example: Let A = {1, 2, 3} B = {a,b} R = {(1,a), (1,b), (3,a)} Furthermore 1Ra, 2Rb, 3Ra, 3Rb Total relations from A to B A x B = total relations from A to B Example: Let A = {1, 2, 3} B = {a, b} Total relations from A to B R = {(1, a), (1, b), (2, a), (2, b), (3, a), (3, b)} Check: | A | x | B | = 3 x 2 = 6 Solution Set R* of the relation R

It consist of elements (a,b) in A x B for which P(a,b) is true, where R* A x B Example: Let A = {1, 2, 3, 4} B = {2, 3, 4, 5, 6}

1. P(x,y) reads “x is less than y” R* = {(1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (2, 3), (2, 4), ( 2, 5), (2, 6), (3, 4), (3, 5), (3, 6), (4, 5), (4, 6)}

2. P(x,y) reads “x is greater than y”

R* = {(3, 2), (4, 2), (4, 3)}

Page 22: MELJUN CORTES Instructional Manual Multimedia

College of Computer Studies

22

MELJUN P. CORTES, MBA,MPA Coordinate Diagram of Relation R from A to B It consists of those points on the coordinate diagram of AxB which belong to the solution set of R*. Example: A = {1, 2, 3, 4}

B = {2, 3, 4, 5, 6} P(x,y) = “x is less than y” R* = {(1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (2, 3), (2, 4), (2, 4), (2, 5),

(2, 6), (3, 4), (3, 5), (3, 6), (4, 5), (4, 6)}

Inverse Relation (R-1)

The pairs of R with the order of elements reversed. Example: R = {(1, 2), (2, 3), (2, 4)}

R-1 = {(2, 1), (3, 2), (4, 2)} Partition or Quotient Set It is a collection of P non-empty set subsets of A such that:

1. Each element of A belongs to one of the sets in P.

2. If A1 and A2 are distinct elements of P then A1 A2 =

Blocks or cells of partitions – the sets in P

P = {A1, A2, A3, A4, A5, A6, A7}

Example: Let A = {a, b, c, d, e, f, g, h} A1 = {a, b, c, d} A2 = {a, c, e, f, g, h} A3 = {a, c, e, g} A4 = {b, d} A5 = {f, h} 1. {A1, A2} = not P 2. {A1, A5} = not P 3. {A3, A4, A5} = P 4. {A2, A4} = P

Page 23: MELJUN CORTES Instructional Manual Multimedia

College of Computer Studies

23

MELJUN P. CORTES, MBA,MPA Set Arising from Relation R

1. Domain of R or dom R Set of the first coordinate of R.

2. Range of R or ran R Set of the second coordinate of R.

Example: Let A = {1, 2, 3} B = {3, 4, 5}

R = {(1,2), (2, 3), (1, 3)} dom R = {1, 2} ran R1 = {2,3} Relative set of x R(x) It is the set of all y in B with the properties that is x is related to y.

Example: Let : A = {1, b, c, d} R = {(a, a), (a, b), (b, c), (c, a), (a, c), (c, b)} Find: 1. R(a) = {a, b, c} 2. R(b) = {c} 3. R(c) = {a, b}

4. R(d) = { } R Relative Set of A1 R(A1)

It is the set of all y in b with the property that is R-related to y for some x in A1

Note: R(A1) is the union of the sets R(x) where x A.

Example: Determine R(A1) and R(A2) if

A1 = {a, b} and A2 = {c, d}

Find: 1. R(A1) = {a, b, c}

2. R(A2) = {a, b}

MIDTERM EXAMINATION

Page 24: MELJUN CORTES Instructional Manual Multimedia

College of Computer Studies

24

MELJUN P. CORTES, MBA,MPA

FINAL PERIOD

Matrix of a Relation MR

It is a rectangular array of numbers arranged in m horizontal rows and n vertical columns.

Note: 0 if (a, b) R

1 if (a, b) R Examples:

1. Let A= {1, 2, 3} B = {r, s} R = {(1, r), (2, s), (3, r)} MR = 1 0

0 1 1 0

2. Let A = {a1, a2, a3} B = {b1, b2, b3, b4} R = {(a1, b1), (a1, b4), (a2, b2), (a2, b3), (a3, b1), (a3, b3)} MR= 1 0 0 1

0 1 1 0 1 0 1 0

Digraphs or Directed Graphs It is a pictorial representation of R. Elements of Digraph:

1. Vertices It is a circle containing the elements of A

2. Edges It is a directed line from ai to aj if ai R aj.

Page 25: MELJUN CORTES Instructional Manual Multimedia

College of Computer Studies

25

MELJUN P. CORTES, MBA,MPA

1

2

3

4

1

2

3

4

1

2

3

4

Example #1: A = {1, 2, 3, 4} R = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 3), (2, 4), (3, 4), (4, 1), (4, 4)}

Example #2: A = {1, 2, 3, 4} R = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 3), (4, 4), (3, 4), (4, 3), (2, 3), (1, 4), (2, 4)}

In – Degree It is the number of edges terminating the vertex. Out – Degree It is the number of edges leaving the vertex.

Restriction of R to B = R (B x B)

Example: A = {a, b, c, d, e, f}

B = {a, b, c} R = {(a, c), (b, c), (c, d), (a, e), (c, e)} BxB = {(a, a), (a, b), (a, c), (b, a), (b, b), (b, c), (c, a), (c, b), (c, c)}

Restriction of R to B = {(a, c), (b, c)}

Vertices 1 2 3 4

In 2 2 3 4

Out 3 4 2 2

Page 26: MELJUN CORTES Instructional Manual Multimedia

College of Computer Studies

26

MELJUN P. CORTES, MBA,MPA

1 2 3

5 4

Path Relations and Digraphs Path Length In R from a to b is finite sequence beginning with a and ending with b. Example:

1 path length is 4, vertex 1 to 3

1 = 1, 2, 5, 4, 3 = 1, 2, 2, 4, 3 = 1, 2, 2, 2, 3

2 path length is 3 vertex 1 to 1

2 = 1, 2, 5, 1

3 path length is 1 vertex 1 to 2

3 = 1, 2 Path Composition (Refer to example of path length)

2 o 1 = 1 + 2 = 1, 2, 5, 4, 3 + 1, 2, 5, 1 = no path composition

1 o 2 = 2 + 1 = 1, 2, 5, 1 + 1, 2, 5, 4, 3 = 1, 2, 5, 1, 2, 5, 4, 3

3 o 2 = 2 + 3 = 1, 2, 5, 1 + 1, 2 = 1, 2, 5, 1, 2

2 o 3 = 3 + 2 = 1, 2 + 1, 2, 5 = no path composition Cycle a path that begins and ends at the same vertex

Example: 2

n – ary relation (Rn)

If n is a fixed positive integer, we define a relation Rn as:

x Rny means that there is a path length n from x to y in R.

R1 = path length of 1 connecting the vertices

R2 = path length of 2 connecting the vertices

R3 = path length of 3 connecting the vertices

Rn = path length of 4 connecting the vertices

Page 27: MELJUN CORTES Instructional Manual Multimedia

College of Computer Studies

27

MELJUN P. CORTES, MBA,MPA

1 2 3

4 5 6

1 2 3

4 5 6

Example: Let A = {1, 2, 3, 4, 5, 6} R = {(1, 2), (1, 4), (2, 2), (2, 4), (2, 5), (3, 4), (4, 5), (5, 6)} Digraph of R

R2 = {(1, 2), (1, 4), (2, 2), (2, 4), (2, 5), (3, 4), (4, 5), (5, 6)}

Digraph of R2

Find the R (connectivity relation for R)

R = {(a, a), (a, b), (a, c), (a, d), (a, e), (b, c), (b, d), (b, e), (c, d)}

a b

c d

3

Page 28: MELJUN CORTES Instructional Manual Multimedia

College of Computer Studies

28

MELJUN P. CORTES, MBA,MPA

Properties of Relation 1. Reflexive every element of A is related to itself.

Example: A = {1, 2, 3} R {(1, 1), (2, 2), (3, 3)}

Irreflexive no element of A is related to itself. Example: A = {1, 2, 3} R = {(1, 2), (2, 3), (3, 1), (1, 3), (3, 2), (2, 1)} 2. Symmetric whenever (a,b) is in R, (b,a) is also in R. Example: A = {1, 2, 3} R = {(1, 2), (2, 3), (3, 1), (1, 3), (3, 2), (2, 1)} Assymetric whenever (a,b) is in R, (b, a) is not in R. Example: A = {1, 2, 3} R = {(1, 3), (2, 3), (1, 2)} 3. Transitive whenever (a,b) is in R, (b,c) is also in R, (a,c) is in R also. Example: A = {1, 2, 3}

R = {(1, 2), (2, 3), (1, 3), (1, 1), (2, 2), (3, 3)} Note: whenever R is reflexive, the given R is also transitive. Equivalance Relations It is a relation in set A is an equivalence R if a. relation is reflexive b. relation is symmetric c. relation is transitive Example: A = {1, 2, 3} R = {(1, 2), (2, 3), (3, 2), (2, 1), (1, 3), (1, 1), (3, 1), (2, 2), (3, 3)} Equivalence of R determined by P Example #1: Let A = {1, 2, 3, 4} P = {{1, 2, 3}, {4}} Equivalence of R determined by P = {(1, 1), (1, 2), (1, 3), (2, 1),

(2, 2), (2, 3), (3, 1), (3, 2), (3, 3), (4, 4)} Example #2: Let A = {1, 2, 3, 4} P = {{1, 2}, {3, 4}} Equivalence of R determined by P = {(1, 1), (1, 2), (2, 1),

(2, 2), (3, 3), (3, 4), (4, 3), (4, 4)}

Page 29: MELJUN CORTES Instructional Manual Multimedia

College of Computer Studies

29

MELJUN P. CORTES, MBA,MPA Equivalence classes A/R It is a partition of set A determine by the equivalence relation R on A. Sets within a set. Example: Let A = {1, 2, 3, 4} R = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 3), (3, 4), (4, 3), (4, 4)} Find A/R

R(1) = {1, 2} R(3) = {3, 4} R(2) = {1, 2} R(4) = {3, 4} A/R = {(1, 2), (3, 4)} MANIPULATION OF RELATION __ Complementary R or R a R b if a R b

R S = a(R S)b = aRb and aSb

R S = a(R S)b = aRb and aSb

Inverse R R-1 It is a relation from B to A (a reverse order from R)

b R-1 a if a R b Example #1: Let A = {1, 2, 3, 4} B = {a, b, c} R = {(1, a), (1, b), (2, b), (2, c), (3, b), (4, a)} S = {(1, b), (2, c), (3, b), (4, b)} AxB = {(1, a), (1, b), (1, c), (2, a), (2, b), (2, c), (3, a), (3, b), (3, c), (4, a), (4, b), (4, c)} Find: __

1.R = {(1, c), (2, a), (3, a), (3, c), (4, b), (4, c)}

2. R S = {(1, b), (2, c), (3, b)}

3.R S = {(1, a), (1, b), (2, b), (2, c), (3, b), (4, a), (4, b)}

4. R-1 = {(a, 1), (b, 1), (b, 2), (c, 2), (b, 3), (a, 4)} 5. S = {(1, a), (1, c), (2, a), (2, b), (3, a), (3, c), (4, a), (4, c)}

6. S-1 = {(b, 1), (c, 2), (b, 3), (b, 4)}

Page 30: MELJUN CORTES Instructional Manual Multimedia

College of Computer Studies

30

MELJUN P. CORTES, MBA,MPA Example #2: Let A = {a, b, c, d, e} R S

Find:_ 1. R = {(a, a), (a, c), (b, a), (b, b), (c, a), (c, b), (c, d), (c, e), (d, a), (d, b), (d, e), (e, a)(e, b), (e, c), (e, d)}

2. R S = {(a, b), (b, e), (c, c)}

2. R S = {(a, a), (a, b), (a, d), (a, e), (b, b), (b, c), (b, d), (b, e), (c, b), (c, c), (c, e),(d, b), (d, c), (d, d), (e, a), (e, d), (e, e)}

4. R-1 = {(b, a), (d, a), (e, a), (c, b), (d, b), (e, b), (c, c), (c, d), (d, d), (e, e)} 5. S = {(a, c), (a, d), (a, e), (b, a), (b, c), (b, d), (c, a), (c, d), (d, a), (d, c), (d, d), (d, e),(e, b), (e, c), (e, e)}

6. S-1 = {(a, a), (b, a), (b, b), (e, b), (b, e), (c, c), (e, c), (b, d), (a, e), (d, e)} Example #3: Let A = {1, 2, 3} MR = 1 0 1 MS = 0 1 1

0 1 1 1 1 0 0 0 0 0 1 0

Find: 1. MR = 0 1 0 4. MRS = 1 1 1

1 0 0 1 1 1 1 1 1 0 1 0

2. MRS= 0 1 1 5. MS-1 0 1 0

1 1 0 1 1 1 0 1 0 1 0 0

3. MR-1= 1 0 0 6. MS = 1 0 0

0 1 0 0 0 1 1 1 0 1 0 1

Composition

b

a c

e d

b

a c

e d

Page 31: MELJUN CORTES Instructional Manual Multimedia

College of Computer Studies

31

MELJUN P. CORTES, MBA,MPA

Composition of R and S (S o R) It is a relation from A to C It is a is in A and c is in C then a(SoR)c if for some b in B, we have aRb and bRc. Note: MS o R = MR o MS

Example #1: Let A = {1, 2, 3,4} R = {(1, 2), (1, 1), (1, 3), (2, 4), (3, 2)} S = {(1, 4), (1, 3), (2, 3), (3, 1), (4, 1)} S o R = {(1, 3), (1, 4), (1, 1), (2, 1), (3, 3)} R o S = {(1, 2), (2, 2), (3, 2), (3, 1), (3, 3), (4, 2), (4, 1), (4, 3)} Example #2: MR = 1 0 1 MS = 1 0 0

1 1 1 0 1 1 0 1 0 1 0 1 Find: 1. MSoR = 1 0 1

1 1 1 0 1 1

R1-C1 R2-C2 R3-C1 R1-C2 R2-C2 R3-C2 1 – 1 1 – 1 0 – 1 1 – 0 1 – 0 0 – 1 0 – 0 1 – 0 1 – 0 0 – 1 1 – 1 1 – 1 1 – 1 1 – 1 0 – 1 1 – 0 1 – 0 0 – 0 R1 – C3 R2 – C2 R3 – C1 1 – 0 1 – 0 0 – 0 0 – 1 1 – 1 1 – 1 1 – 1 1 – 1 0 – 1 2. MRoS = 1 0 1

1 1 1 1 1 1

R1 – C1 R2 – C1 R3 – C1 R1 – C2 R2 – C2 R3 – C2 1 – 1 1 – 1 1 – 1 1 – 0 0 – 0 1 – 0 0 – 1 0 – 1 0 – 1 0 – 1 1 – 1 1 – 0 0 – 0 1 – 0 1 – 0 0 – 1 1 – 1 1 – 1 R1 – C3 R2 – C3 R3 – C3 1 – 1 0 – 1 1 – 1 0 – 1 1 – 1 0 – 1 1 – 0 1 – 0 1 – 0

Page 32: MELJUN CORTES Instructional Manual Multimedia

College of Computer Studies

32

MELJUN P. CORTES, MBA,MPA FUNCTIONS Functions or Mapping or Transformation Functions To each element in A, there is assigned a unique element of B. It is a special class or relation. Note: Not all relations can be considered as a function. A binary relation R from A to B is said to be a function if for every element a in A, there is a unique element b in B so that (a,b) is in R. For function f from A to B, instead

of writing (a,b)R, the notation f(a) = b is also used where b is the image of a.

It is a A, then the element belonging to set B which is assigned to a is called the image of a and is denoted by f(a), which is said as “f of a” f denotes the assignment of R from A to B f: A B = f is function from A to B = f maps A into B f: A B Conditions for Functions

1. For every element a A, only one element b B is assigned. 2. All elements in A must be used up by the functions. 3. Not all elements in B must be used up by the functions. 4. The function may pair more than one input a to the same output b.

Example: 1. a 0 2. a 0 b 1 b 1 c 2 c 2 f not a function 3. a 0 4. a 0 b 1 b 1 c 2 c 2 not a function not a function 5. a 0 6. a 0 b 1 b 1 c 2 c 2 f f Way of Defining a Function

Co-domain or range of function f

relation

Domain of function f

function f

Page 33: MELJUN CORTES Instructional Manual Multimedia

College of Computer Studies

33

MELJUN P. CORTES, MBA,MPA Let A = {1, 2, 3, 4} B = {a, b, c, d}

1. Relation F = {(1,a), (2,c), (3,b), (4,d)}

2. Correspondence f(1) = a f(3) = b f(2) = c f(4) = d

3. Diagram 1. .a 1 a 1 a

2. .b 2 b 2 b

3. .c 3 c 3 c

4. .d 4 d 4 d

A B A B A B

4. Rule

A B 1 a 2 b 3 c 4 d

5. Formula

f(x) = x + 1

Identify Function or Identity Transformation on A For a function f : A A defined by the formula f(x) = x, let f assign to each element in A the element itself. Operator or Transformation on A a function of A into itself if the domain and co-domain of a function f are both the same set f : A A Example:

f f f

Page 34: MELJUN CORTES Instructional Manual Multimedia

College of Computer Studies

34

MELJUN P. CORTES, MBA,MPA Let A = {1, 2, 3} 1 1 2 2 3 3

f A A Equal Function If f and g are functions defined on the same domain d and f(a) = g(a) for every a d, then the functions f and g are equal. Example: Let function f and g be defined by the diagram.

1 1 1 2 1 3 2 3 2 9 9 f g f(1) = 1 g(1) = 1 f(2) = 9 g(2) = 9 f = g Range of a Function f = f(a) It consists precisely of those elements in B which appear as the image of at least one element in set A. It consists of all the image points. Note: f(A) B Example.

1. Let f: A B A = {a,b,c,d} B = {a,b,c} Define the function f of A into B by the correspondence f(a) = b, f(b) = c, f(d) = b, then f(A) = {b,c}

2. Let A = {1, 2, 3, 4, 5}

Define the function f A A by the diagram 1 1 f(A) = {2, 3, 5} 2 2 3 3 4 4 5 5 f A A

3. Let A = {-2, -1, 0, 1, 2}

Page 35: MELJUN CORTES Instructional Manual Multimedia

College of Computer Studies

35

MELJUN P. CORTES, MBA,MPA Let the function g: A R# be defined by the formula g(x) = x2 + 1 Find the range of a function g. g(-2) = f g(1) = 2

g(-1) = 2 g(2) = 5 g(A) = {1, 2, 5} g(0) = 1 Constant Function It is the same element b belonging to set B is assigned to every element in set A. f(A) = one element from B Example: Let the function be defined by the diagram a 1 f(A) = 2 b 2 c 3 f A B Even Function If A is a set of nos. such that whenever a A, -a A also and if f: A B is a function satisfying f(a) = f(-a) for each a A. Example:

1 a -1 a

2 b -2 b Inverse of a function f1(b) It consists of those elements in A which have b as their image. f1(b) { x | x A, f(x) = b} f1(b) A Example: a x f1(x) = {b} b y f1(y) = (y,z) c z f1(z) = { } f A B Extended Definition

Page 36: MELJUN CORTES Instructional Manual Multimedia

College of Computer Studies

36

MELJUN P. CORTES, MBA,MPA It consists of those elements in A which are mapped into some elements in the domain. Example: x r f1(r,s) = {x,y} y s f1(r,t) = {y, z} z t f1(B) = f1(r,s,t) = {x,y,z} f A B Inverse function of f f1 B A It must be both one-to-one and onto. Example: a x x a a x b y y b or b y c x z c c z f f1 f1 A B B. A A B Special Types of Function 1. One-to-one (1:1) injection – no two elements in A have the same image. Example: 1 4 1 4 2 5 2 5 3 6 3 6 f f A B A B not one-to-one function 2. Onto function – every element of B is the image of one or more elements of A. Note: f(A) = B Example: a 1 a x b 2 b y c 3 c z f d A B f A B not one-to-one but onto function 3. One-to-one and onto-function – bijection

Page 37: MELJUN CORTES Instructional Manual Multimedia

College of Computer Studies

37

MELJUN P. CORTES, MBA,MPA Example: a 1 b 2 c 3 f A B Composition Function of Product Function f: A B and g: B C f g (g o f) a function A into C. to each element a A a corresponding element f(f(a)) C. Note: (g o f) (a) = g(f(a)) Examples:

1. Compute (g o f): A C by correspondence by diagram 1 4 7 1 7 2 5 8 2 8 3 6 9 3 9 f g g o f A C (g o f) (1) = g(f(1)) = g (5) = 9 (g o f) (2) = g(f(2)) = g (6) = 8 (g o f) (3) = g(f(3)) = g (4) = 7

2. To each real number let f assign its sequence; i.e. f(x) = x2 and to each real number let g assign the number plus 3, i.e., let g(x) = x + 3.

If x = 2, find a. (f o g) b. (g o f)

a. (f o g)(2) = f(g(2)) = f (5) = 25 b. (g o f)(2) = g(f(2)) = g(4) = 7

3.

A B C

Domain of g

Co-domain of g Co-domain of f

domain of f

Page 38: MELJUN CORTES Instructional Manual Multimedia

College of Computer Studies

38

MELJUN P. CORTES, MBA,MPA 1 4 7 10 2 5 8 11 3 6 9 12 f g h A B C D Find by diagram: 1. h o g o f 4. (h o g o f)-1 2. f o g o h 5. (h o g o f)(A)

3. (f o g o h)-1

1. h o g o f 1 4 4 7 7 10 2 5 5 8 8 11 3 6 6 9 9 12 f g h A B B C C D

1 10 2 11 3 12 h o g o f A D

2. f o g o h 7 10 4 7 1 4 8 11 5 8 2 5 9 12 6 9 3 6 h g C D B C A B No product function

3. (f o g o h)-1 no inverse product function

4. (h o g o f)-1 1 10 2 11 3 12 (h o g o f)-1 A D

5. (h o g o f)(A) = {10,11,12} 1. Formula

Page 39: MELJUN CORTES Instructional Manual Multimedia

College of Computer Studies

39

MELJUN P. CORTES, MBA,MPA Let f assign to each real number its square. For every real number x, let f(x) = x2. The domain and co-domain are both real number. f: R# R # The image of -3 = 9 f(-3) = 9 or f: -3 9

2. Geographical Let f assign to each country in the world its capital. Domain of f = set of countries in the world. co-domain of f = list of capital cities in the world.

The image of France = Paris f(France) = Paris 3. Corresponce Let A = {a,b,c,d} B = {a,b,c} f(a) = b f(b) = c f(c) = d 4. Diagram Let A = {a,b,c,d} B = {x,y,z} a x b y c z d A B 5. Relation Let A = {1, 2, 3, 4} B = {a, b, c, d} f = {(1, a), (2, a), (3, d), (4, c)} f(1) = a f(2) = a f(3) = d f(4) = c 6. Let A = {1, 2, 3} B = {x, y, z} R = {(1, x), (2, x)} S = {(1, x), (1, y), (2, z), (3, y)) R S 1 x 1 x 2 y 2 y 3 x 3 z

FINAL EXAMINATION