CS301 – Data Structures Lecture No. 34___________________________________________________________________Data StructuresLecture No. 34Reading MaterialData Structures and Algorithm Analysis in C++ Chapter. 88.1, 8.2, 8.3Summary•Equivalence Relations•Disjoint Sets•Dynamic Equivalence ProblemEquivalence 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 relationif it has following properties’:1.Reflexivity: for all element x ξ S, x R x2.Symmetry: for all elements x and y, x R y if and only if y R x3.Transitivity: for all elements x, y and z, if x R y and y R z then x R zThe 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

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

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 notan equivalence relation. We will prove this by applying the three rules. The first rule is reflexive. It is reflexive, since x ≤ x, as xis not less than xbut surely is equal to x. Let’s check the transitive condition. Since x ≤ y and y ≤ zimplies x ≤ z., it is also true. However it is not symmetricas x ≤ ydoes not imply y ≤ x. Two rules are satisfied but symmetric rule does not. Therefore ≤ is not an equivalence relation.

This is the end of the preview.
Sign up
to
access the rest of the document.