Lesson 4 - Relations

.docx

School

Colorado Technical University *

*We aren’t endorsed by this school

Course

225

Subject

Computer Science

Date

May 13, 2024

Type

docx

Pages

8

Uploaded by chrisjin92 on coursehero.com

Introduction Consider pairing information into sets. For example, you can pair a student with a student ID or a student with a course. The association of sets is referred to as a  relation . In mathematics, a relation is the correspondence between the sets of information. A specific type of relation is a  function . Learning Materials Relations can be represented in multiple ways. In any representation, the order is important and has to remain the same. One form that is used to represent a relation is ordered pairs. Consider the following example of a set of students and a set of student IDs. Set A = {Nick, Erica, Amanda, Olivia} Set B = {10, 12, 14, 16} To write these two sets as a relation, the order must be determined. Each ordered pair in the relation will be (student name, student ID). The relation is as follows: R = {(Nick, 10), (Erica, 12), (Amanda, 14), (Olivia, 16)}. The relation has a domain and a range. The domain is the first coordinate of the ordered pairs, and the range is the second coordinate of the ordered pairs. For the relation in the example, the domain would be the student names, or set A, and the range is the student IDs, or set B. Another method to represent a relation is in tabular form. The domain and range are easily displayed in this form; one column is the domain, and the other is the range. The previous example of student names and student IDs in tabular form is as follows: Student Name     Student ID Nick 10 Erica 12 Amanda 14 Olivia 16 In the example used, two sets are compared. Comparing two sets is referred to as a binary relation. Two sets are not always sufficient enough for the needed amount of information. Relations with more than two sets are n-ary
relations , where n is the number of sets in the relation. A binary set is not the only n-ary with a special name. A relation with three sets is a 3-ary or a ternary relation . Consider adding two additional sets of information to the student name and student ID example. Set C is the student’s gender, and set D is the student’s major, as follows: Set C = {male, female, female, female} Set D = {Business, Education, Science, English} The relation now contains four sets and is a 4-ary relation. The same formats are used to represent the information; although, the tabular form is more transparent. R = {(Nick, 10, male, Business), (Erica, 12, female, Education), (Amanda, 14, female, Science), (Olivia, 14, female, English)} Student Name Student ID Student Gender Student Major Nick 10 Male Business Erica 12 Female Education Amanda 14 Female Science Oliva 16 Female English A function is a relation with a specific requirement. The requirement is that every value in the first set must relate to exactly one element in the second set. In other words, the domain cannot repeat. The relation {(2, 4), (3, 6), (4, 8), (5, 10)} also represents a function. One way to determine whether the relation is a function is to map the domain and range. Notice in the mapping below that each element in the domain maps to only one element in the range. The relation is a function.
The relation {(2, 4), (3, 6), (3, 8), (5, 10)} does not represent a function. The element 3 in the domain relates to both 6 and 8. A graph represents a function only if the graph passes the vertical line test. If a vertical line can be drawn through a graph and can intersect the graph in more than one location, the graph does not represent a function. Example: The following graph represents a function. A vertical line drawn would only intersect the graph one time.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help