{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

06relations_10

# 06relations_10 - ENGG1007 Foundations of Computer Science...

This preview shows pages 1–7. Sign up to view the full content.

1 ENGG1007 Foundations of Computer Science Relations Relations Prof. Francis Chin, Dr SM Yiu Sept 24 / 30, 2010 (Chapters 2.1, 2.2, 8)

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
2 ENGG1007 FCS Relations Relations Consider C ={HK, Beijing, Shanghai, Guangzhou, Nanjing} Every city builds roads to its nearest city. This information ( relationship among cities ) can be represented by a set of 2-tuples ( ordered pairs ) R = { (HK, Guangzhou), (Beijing, Nanjing), (Shanghai, Nanjing), (Guangzhou, HK), (Nanjing, Shanghai) } Ordered pairs are used to indicate relationship between 2 objects . . Note that the ordering of the elements are important!
3 ENGG1007 FCS Relations – Another example Relations – Another example A relation relation can associate objects of one kind with objects of another kind . Example: “Marriage” as a relation. x is a man in HK; y is a woman in HK G is a set of all ordered pairs ordered pairs ( x , y ) where x is a husband of y. John is married to Mary iff (John, Mary) G EG. G = { (John,Mary), (Alex,Cindy), (Joe,Liza) } G is a relation from is a relation from M M (all men in HK) to (all men in HK) to N N (all women in HK) (all women in HK) Example: Universities = {BU, CityU, CU, LU, PU, UST, HKU} Programs = {Eng, Sci, Med, Law, Arts, Bus,…} Offerings = { (CityU, Eng), (CU, Eng), (PolyU, Eng), (UST, Eng), (HKU, Eng), (CityU, Law), (HKU, Law), (CU, Med), (HKU, Med), …} BU CityU CU LU PU UST HKU Eng Sci Med Law Arts Bus

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
4 ENGG1007 FCS Cartesian Products Cartesian Products The Cartesian product of sets A and B , denoted by A × B , is the set of all ordered pairs ( a , b ) where a A and b B . A × B = { ( a , b ) | a A b B }. Example: Cartesian Products of A = { 1, 2, 3 } and B = { a , b } is A × B = { (1, a ), (1, b ), (2, a ), (2, b ), (3, a ), (3, b ) }. Example: All points in the 2-dimensional space, where A and B are sets of real numbers, R, i.e., R × R or R 2 Relation Relation is a subset of the Cartesian Products Example: Roads Cities × Cities Example: Offerings Universities × Programs Example: A=Students, B=Courses, Enrolment A × B
5 ENGG1007 FCS Notation Notation Given a relation R from A to B, a R b a R b iff ( a , b ) R a is said to be related to b by R A relation on the set A relation on the set A is a relation from A to A. e.g. A = { 1, 2, 3, 4 }. R = { ( a, b ) | a divides b } What are the elements of R ? A x A = { (1,1), (1,2), (1,3), (1,4), (2,1), (2,2), (2,3), (2,4), (3,1), (3,2), (3,3), (3,4), (4,1), (4,2), (4,3), (4,4) } R = { (1,1), (1,2), (1,3), (1,4), (2,2), (2,4), (3,3), (4,4) } 1 2 3 4 Directed Graph

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
6 ENGG1007 FCS Properties of Relations – Reflexive Properties of Relations – Reflexive A relation R on a set A is called reflexive reflexive if ( a,a ) R for all a A.
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 22

06relations_10 - ENGG1007 Foundations of Computer Science...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online