DISCSA3 (REVIEWER)

.pdf
School
University of Santo Tomas**We aren't endorsed by this school
Course
COMPUTER S 122
Subject
Computer Science
Date
Dec 15, 2024
Pages
18
Uploaded by LieutenantPigeonPerson626
MODULE 5:RELATIONS CS0001 (DISCRETE STRUCTURES 1) 1 subtopic 1:INTRODUCTION TO RELATIONS RELATIONS β€’these are derived from a Cartesian productβ€’a binary relation 𝑅from ?to ?is a set of ordered pairs where first element is from set ?and the second element is from set ?β€’e.g., ? = {1, 2}, ? = {?, ?, ?}? Γ— ? = {(1, ?), (1, ?), (1, ?), (2, ?), (2, ?), (2, ?)}DOMAIN & RANGE OF A RELATION β€’DOMAINothis is defined as the set of all the first elements in the ordered pairβ€’RANGEothis is defined as the set of all the second elements in the ordered pairβ€’e.g., ? = {1, 2, 3, 5}, ? = {4, 6, 9}oSET BUILDER: 𝑅is a relation from set ?to ?such that:𝑅 = {(?, ?), difference of ? and ? is odd, ? ∈ ? and ? ∈ ?}oSET ROSTER:𝑅 = {(1,4), (1,6), (2,9), (3,4), (3,6), (5,4), (5,6)}β–ͺDOMAIN: {1, 2, 3, 5}β–ͺRANGE: {4, 6, 9}
Background image
MODULE 5: RELATIONSsubtopic 1: introduction to relationsCS0001 (DISCRETE STRUCTURES 1) 2 EXAMPLE PROBLEM (DOMAIN & RANGE) Find the domain and range of the relation below: β€’SET BUILDER:𝑅 = {(?, ?) ∢ ? = ? +6?where ? and ? ∈ β„• and ? < 6}β€’to find the elements of the set roster, we have to find the minimum and maximum value for ?which satisfies the condition set in the set builder:othe possible values of ?need to be a natural number and less than 6, but we have to check if all values for ?are also natural numbers:? = {1, 2, 3, 4, 5}𝐒? ? = ?:? = 1 +61= 7 ∈ ℕ𝐒? ? = ?:? = 2 +62= 5 ∈ ℕ𝐒? ? = ?:? = 3 +63= 5 ∈ ℕ𝐒? ? = ?:? = 4 +64=112βˆ‰ ℕ𝐒? ? = ?:? = 5 +65=315βˆ‰ β„•β€’SET ROSTER: {(1,7), (2,5), (3,5)}oDOMAIN: {?, ?, ?}oRANGE: {?, ?}
Background image
MODULE 5: RELATIONSsubtopic 1: introduction to relationsCS0001 (DISCRETE STRUCTURES 1) 3 ARROW DIAGRAM β€’e.g., ? = {1, 2, 3, 4, 5}, ? = {2, 3, 4, 5, 6, 7, 8}oSET BUILDER: 𝑅is a relation from set ?to ?such that:𝑅 = {(?, ?) ∢ ? = ? + 1, βˆ€? ∈ ? and ? ∈ ?}oSET ROSTER:𝑅 = {(1,2), (2,3), (3,4), (4,5), (5,6)}oARROW DIAGRAM:REPRESENTING RELATIONS USING DIAGRAMS β€’DIGRAPHothis is a pictorial representation of a relationoit consists of a set 𝑉of VERTICES (or nodes) together with a set 𝐸of ordered pairs of elements of 𝑉, called EDGES (or arcs)β€’VERTEXothis is called the initial vertex of edge (?, ?), with ?as the terminating vertexβ€’e.g., represent this relation with a digraph:𝑅 = {(?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?)}
Background image
MODULE 5: RELATIONSsubtopic 1: introduction to relationsCS0001 (DISCRETE STRUCTURES 1) 4 REFLEXIVE, SYMMETRIC, & TRANSITIVE RELATIONS β€’a relation on ?is REFLEXIVE if: ?𝑅?, βˆ€? ∈ ?oin layman’s terms, a relation is reflexive if for all element in set ?, that element is related or maps to itself in relation 𝑅β–ͺnotice how ?, ?, and ?all loop back to itself, denoted by the circular arrowonote that all elements must map to itself, since if there is one element that doesn’t, it cannot be called reflexiveβ€’a relation on ?is SYMMETRIC if:βˆ€?, ? ∈ ?if ?𝑅?then ?𝑅?oa symmetric relation is a binary relation 𝑅defined on a set ?for elements ?, ? ∈ ?, we have ?𝑅?, that is, (?, ?) ∈ 𝑅, then we must have ?𝑅?, that is, (?, ?) ∈ 𝑅
Background image
MODULE 5: RELATIONSsubtopic 1: introduction to relationsCS0001 (DISCRETE STRUCTURES 1) 5 othis implies that a relation defined on a set A is a symmetric relation if and only if it satisfies ?𝑅? ↔ ?𝑅?for all elements ?, ? in ?oif there is a single ordered pair in 𝑅such that (?, ?) ∈ 𝑅 and (?, ?) βˆ‰ 𝑅, then 𝑅is not a symmetric relation β€’a relation is TRANSITIVE if:βˆ€?, ?, ? ∈ ?if ?𝑅?and ?𝑅?then ?𝑅?otransitive relations are binary relations defined on a set such that if the first element is related to the second element, and the second element is related to the third element of the set, then the first element must be related to the third elementofor example, if for three elements ?, ?, ? in set ?, if ? = ? and ? = ?, then ? = ?β–ͺin this example, equality '=' is a transitive relation
Background image
MODULE 5: RELATIONSsubtopic 1: introduction to relationsCS0001 (DISCRETE STRUCTURES 1) 6 RELATIONS & THEIR INVERSE β€’the inverse relation to 𝑅is denoted by π‘…βˆ’1and is a subset of ? Γ— ?
Background image
MODULE 5: RELATIONSsubtopic 2: composition of relationsCS0001 (DISCRETE STRUCTURES 1) 7 subtopic 2:COMPOSITION OF RELATIONS COMPOSITION OF RELATIONS β€’we can combine relations in the same manner we combine any other setsβ€’e.g., let ? = {1, 2, 3, 4}, ? = {0, 1, 2}𝑅1= {(1,0), (1,2), (1,1), (2,2)}𝑅2= {(1,1), (3,2), (4,2)}ofind the following:(𝑅1βˆͺ 𝑅2) = {(1,0), (1,1), (1,2), (1,1), (2,2), (3,2), (4,2)}(𝑅1∩ 𝑅2) = {(1,1)}(𝑅1βˆ’ 𝑅2) = {(1,0), (1,2), (2,2)}(𝑅2βˆ’ 𝑅1) = {(3,2), (4,2)}COMPOSITING RELATIONS β€’let 𝑅, be a relation from set ?to set ?, and let 𝑅2be a relation from set ?to set ?othe composition 𝑅1∘ 𝑅2consists of the ordered pairs (?, ?), such that ? ∈ ?, ? ∈ ?, ? ∈ ?, (?, ?) ∈ 𝑅1, and (?, ?) ∈ 𝑅2β€’e.g., what is 𝑅1∘ 𝑅2if 𝑅1is a relation from {1, 2, 3}to {1, 2, 3, 4}with 𝑅1= {(1,1), (1,3), (1,4), (2,3), (3,1),(3,4)}and 𝑅2is a relation from {1, 2, 3, 4}to {0, 1, 2}where 𝑅2= {(1,0), (2,0), (3,1), (3,2), (4,1)}𝑅1∘ 𝑅2= {(1,0), (1,1), (1,2), (2,1), (2,2), (3,0), (3,1)}
Background image
MODULE 5: RELATIONSsubtopic 2: composition of relationsCS0001 (DISCRETE STRUCTURES 1) 8 EQUIVALENCE OF RELATIONS β€’a relation is said to be an equivalence relation if it is reflexive, symmetric, and transitiveβ€’REFLEXIVEoβˆ€? ∈ ?, (?, ?) ∈ 𝑅oe.g., ? = {1, 2, 3}β–ͺ(1,1) ∈ 𝑅β–ͺ(2,2) ∈ 𝑅β–ͺ(3,3) ∈ 𝑅‒NOT REFLEXIVEoβˆƒ? ∈ ?, (?, ?) βˆ‰ 𝑅‒SYMMETRICo?, ? ∈ ?, (?, ?) ∈ 𝑅, (?, ?) ∈ 𝑅oe.g., ? = {1, 2, 3}β–ͺ𝑅 = {(1,2), (2,1)}β€’NOT SYMMETRICoβˆƒ?, ? ∈ ?, (?, ?) ∈ 𝑅, (?, ?) βˆ‰ 𝑅‒TRANSITIVEo?, ?, ? ∈ ?, (?, ?) ∈ 𝑅, (?, ?) ∈ 𝑅, (?, ?) ∈ 𝑅oe.g., ? = {1, 2, 3}β–ͺ𝑅 = {(1,2), (2,3), (1,3)}β€’NOT TRANSITIVEoβˆƒ?, ?, ? ∈ ?, (?, ?) ∈ 𝑅, (?, ?) ∈ 𝑅, (?, ?) βˆ‰ 𝑅EXAMPLE PROBLEM (EQUIVALENCE OF RELATIONS) Check if the following relation is an equivalence relation: 𝑹 = {(?, ?) ∢ ? 𝐒𝐬 ?𝐒𝐯𝐒𝐬𝐒𝐛π₯? 𝐛𝐲 ?, ?, ? ∈ 𝑡}β€’SOLUTION:ofirst, check its REFLEXIVITY:β–ͺsince any natural number is divisible by itself, this relation is reflexiveβ–ͺe.g., 3is divisible by 3,and so on
Background image
MODULE 5: RELATIONSsubtopic 2: composition of relationsCS0001 (DISCRETE STRUCTURES 1) 9 onext, check its SYMMETRY:β–ͺlet’s say we have ? = 3and ? = 6β–ͺalthough we can say that 6is divisible by 3, we cannot say the same for the other way around (that is, 3is not divisible by 6) β–ͺtherefore, it is NOT symmetricalosince it does not meet the second condition, there is no need to check its TRANSITIVITY, and we can already conclude that it is NOT an equivalence relation𝒏-ARY RELATIONS β€’a BINARY relation involves two sets and can be described by a set of pairsβ€’a TERNARY relation involves three sets and can be described by a set of triplesβ€’an 𝑛-ary relation involves 𝑛sets and can be described by a set of 𝑛-tuplesoan 𝑛-ary relation is a relation between ANY number of values
Background image
MODULE 6:FUNCTIONS CS0001 (DISCRETE STRUCTURES 1) 10 subtopic 1:INTRODUCTION TO FUNCTIONS FUNCTIONS β€’a function is a connection between two sets ?and ?such that all elements in ?are associated to some elements in ?oNOTE: this association is uniqueβ€’e.g., ?: ? β†’ ?(that is, ?(?) = ?or (?, ?) ∈ ?)? = {1, 2, 3, 4}? = {1, 5, 9, 11, 15, 16}o?1= {(1,1), (2,11), (3,1), (4,15)}β–ͺsince there are no repeating values for the ?values and all values exist in either set, it is a FUNCTIONo?2= {(1,1), (2,7), (3,5)}β–ͺsince 7is a ?value even though it does not exist in ?, this is NOT a functiono?3= {(1,5), (2,9), (3,1), (4,5), (2,11)}β–ͺsince the ?value 2repeats, even though all elements exist in either set, this is still NOT a functionDOMAIN OF A FUNCTION β€’this is the INPUT, or the INSIDE of the function ?(?)β€’in ?(?), it is composed of all values of ?for which ?(?)is definedβ€’e.g., ?(?) = ?3βˆ’ 3onote that you can plug in any value for ?, as long as ? ∈ ℝotherefore, ℝbecomes the DOMAIN for the given function
Background image
MODULE 6: FUNCTIONSsubtopic 1: introduction to functionsCS0001 (DISCRETE STRUCTURES 1) 11 β€’how can we ensure that our function stays defined or gives a valid answer/output?ofirst, ensure that the denominator of a function can never be 0othen, check if the expression inside the square root √ (or any root with even index) evaluates to β‰₯ 0(zero or positive)EXAMPLE PROBLEM (DOMAIN OF A FUNCTION) Find the domain of the function below: ?(?) =??+ ?? + ???βˆ’ ?? + ??β€’SOLUTIONofirst, split the denominator into linear factors and equate it to zero (because the denominator cannot be zero)?2βˆ’ 8? + 12 β‰  0(? βˆ’ 6)(? βˆ’ 2) β‰  0? βˆ’ 6 β‰  0? β‰  6? βˆ’ 2 β‰  0? β‰  2otherefore, the domain must be every real number except 6and 2β–ͺthat is, DOMAIN: ℝ βˆ’ {2, 6}RANGE OF A FUNCTION β€’to find the range of a function, follow these steps:oSTEP 1: put ? = ?(?)oSTEP 2: express ?as the function of ?oSTEP 3: find the possible values of ?
Background image
MODULE 6: FUNCTIONSsubtopic 1: introduction to functionsCS0001 (DISCRETE STRUCTURES 1) 12 oSTEP 4: eliminate values by looking at the definition to write the rangeβ€’the range of a function is the set of all possible values that the function can output given its domainEXAMPLE PROBLEM (RANGE OF A FUNCTION) Find the range of the function below: ?(?) =? βˆ’ ?? βˆ’ ?β€’SOLUTION:ofirst, equate the function to ?? βˆ’ 23 βˆ’ ?= ?othen, express ?as the function of ?by isolating the ?variable (start by cross-multiplying in this case)? βˆ’ 2 = ?(3 βˆ’ ?)? βˆ’ 2 = 3? βˆ’ ??? + ?? = 3? + 2?(1 + ?) = 3? + 2? =?? + ?? + ?onow, find the values of ?that would make the denominator zero (hence, excluding it from the range set) by equating it to 0
Background image
MODULE 6: FUNCTIONSsubtopic 1: introduction to functionsCS0001 (DISCRETE STRUCTURES 1) 13 1 + ? β‰  0? β‰  βˆ’1otherefore, the range is the set of real numbers except ? = βˆ’1β–ͺthat is, RANGE: ℝ βˆ’ {βˆ’1}INJECTIVE (ONE-TO-ONE) FUNCTIONS β€’these are functions where each value in the range corresponds to exactly one element in the domainβ€’that is, βˆ€?βˆ€? ((? β‰  ?) β†’ (?(?) β‰  ?(?)))SURJECTIVE (ONTO) FUNCTIONS β€’these are functions where every element in the codomain (range) maps to at least one element in the domainβ€’that is, βˆ€?βˆƒ? = (?(?) = ?)
Background image
MODULE 6: FUNCTIONSsubtopic 1: introduction to functionsCS0001 (DISCRETE STRUCTURES 1) 14 BIJECTIVE FUNCTIONS β€’these are functions that are both INJECTIVE and SURJECTIVEβ€’e.g.,
Background image
MODULE 6: FUNCTIONSsubtopic 2: composition of functionsCS0001 (DISCRETE STRUCTURES 1) 15 subtopic 2:COMPOSITION OF FUNCTIONS FUNCTION OPERATIONS β€’say you have these two functions ?and ?:?(?) = 2? + 5?(?) = ?2βˆ’ 4β€’ADDITION:(? + ?)(?) = (2? + 5) + (?2βˆ’ 4)(? + ?)(?) = ??+ ?? + ?β€’SUBTRACTION: (? βˆ’ ?)(?) = (2? + 5) βˆ’ (?2βˆ’ 4)(? βˆ’ ?)(?) = (2? + 5) βˆ’ ?2+ 4(? βˆ’ ?)(?) = βˆ’??+ ?? + ?β€’MULTIPLICATION:(? β‹… ?)(?) = (2? + 5)(?2βˆ’ 4)(? β‹… ?)(?) = ???+ ???βˆ’ ?? βˆ’ ??β€’NOTE: the domain of the functions formed by these first three operations are ALL REAL NUMBERS ℝ‒DIVISION: (??)(?) =2? + 5?2βˆ’ 4β€’however, for division, the domain is:
Background image
MODULE 6: FUNCTIONSsubtopic 2: composition of functionsCS0001 (DISCRETE STRUCTURES 1) 16 ?2βˆ’ 4 β‰  0(? + 2)(? βˆ’ 2) β‰  0? + 2 β‰  0? β‰  βˆ’2? βˆ’ 2 β‰  0? β‰  2othe DOMAIN of ?/? would be all real numbers except Β±2β–ͺthat is, DOMAIN: ℝ βˆ’ {βˆ’2, 2}COMPOSITION OF TWO FUNCTIONS β€’this is when a function is substituted as β€œinput” to another functionβ€’e.g.,?(?) = ? + 3?(?) = ?2βˆ’ 5o(? ∘ ?)(?)(? ∘ ?)(?) = ?(?(?)) = (?2βˆ’ 5) + 3(? ∘ ?)(?) = ??βˆ’ ?o(? ∘ ?)(?)(? ∘ ?)(?) = ?(?(?)) = (? + 3)2βˆ’ 5(? ∘ ?)(?) = ?(?(?)) = (?2+ 6? + 9) βˆ’ 5(? ∘ ?)(?) = ??+ ?? + ?
Background image
MODULE 6: FUNCTIONSsubtopic 2: composition of functionsCS0001 (DISCRETE STRUCTURES 1) 17 GRAPHING A BASIC FUNCTION β€’e.g., graph the function ?(?) = 5? βˆ’ 4
Background image
MODULE 6: FUNCTIONSsubtopic 2: composition of functionsCS0001 (DISCRETE STRUCTURES 1) 18 INVERSE OF A FUNCTION β€’this is when you swap the ?and ?variable of the function and then solve for ?by isolating itβ€’e.g., find the inverse of ?(?) = 2? βˆ’ 7? = 2? βˆ’ 7? = 2? βˆ’ 7? + 7 = 2?? + 72= ?otherefore, the inverse function of ?(?) is:?βˆ’?(?) =? + ??β€’e.g., find the inverse of ?(?) = ?3+ 8? = ?3+ 8? = ?3+ 8? βˆ’ 8 = ?3√? βˆ’ 83= ?otherefore, the inverse function of ?(?)is:?βˆ’?(?) = √? βˆ’ ??
Background image