CS301-Lec34 handout - CS301 Data Structures Lecture No. 34...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CS301 – Data Structures Lecture No. 34 ___________________________________________________________________ Data Structures Lecture No. 34 Reading Material Data Structures and Algorithm Analysis in C++ Chapter. 8 8.1, 8.2, 8.3 Summary Equivalence Relations Disjoint Sets Dynamic Equivalence Problem Equivalence Relations We will continue discussion on the abstract data structure, ‘disjointSets’ in this lecture with special emphasis on the mathematical concept of Equivalence Relations. You are aware of the rules and examples in this regard. Let’s discuss it further and define the concept of Equivalence Relations. ‘A binary relation R over a set S is called an equivalence relation if it has following properties’: 1. Reflexivity: for all element x ξ S, x R x 2. Symmetry: for all elements x and y, x R y if and only if y R x 3. Transitivity: for all elements x, y and z, if x R y and y R z then x R z The relation “is related to” is an equivalence relation over the set of people. This is an example of Equivalence Relations. Now let’s see how the relations among people satisfy the conditions of Equivalence Relation. Consider the example of Haris, Saad and Ahmed. Haris and Saad are related to each other as brother. Saad and Ahmed are related to each other as cousin. Here Haris “is related to” Saad and Saad “is related to” Ahmed. Let’s see whether this binary relation is Equivalence Relation or not. This can be ascertained by applying the above mentioned three rules. First rule is reflexive i.e. for all element x ξ S, x R x . Suppose that x is Haris so Haris R Haris . This is true because everyone is related to each other. Second is Symmetry: for all elements x and y, x R y if and only if y R x . Suppose that y is Saad. According to the rule, Haris R Saad if and only if Saad R Haris . If two persons are related, the relationship is symmetric i.e. if I am cousin of someone so is he. Therefore if Haris is brother of Saad, then Saad is certainly the brother of Haris. The family relationship is symmetric. This is not the symmetric in terms of respect but in terms of relationship. The transitivity is: ‘for all elements x, y and z . If x R y and y R z , then x R z ’. Suppose x is Haris, y is Saad and z is Ahmed. If Haris “is related to” Saad, Saad “is related to” Ahmed. We can deduce that Haris “is related to” Ahmed. This is also true in
Background image of page 1

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

View Full DocumentRight Arrow Icon
CS301 – Data Structures Lecture No. 34 ___________________________________________________________________ relationships. If you are cousin of someone, the cousin of that person is also related to you. He may not be your first cousin but is related to you. Now we will see an example of binary relationship that is not based on equivalence relationship. The ≤ relationship is not an equivalence relation. We will prove this by applying the three rules. The first rule is reflexive. It is reflexive, since x ≤ x , as x is not less than x but surely is equal to x . Let’s check the transitive condition. Since
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 05/21/2010 for the course CS CS301 taught by Professor Dr.naveed malik during the Spring '10 term at Virtual University of Pakistan.

Page1 / 7

CS301-Lec34 handout - CS301 Data Structures Lecture No. 34...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online