Docsity

Binary Relations and Equivalence Relations: Definitions and Disjoint Sets - Prof. Jun Huan, Study notes of Data Structures and Algorithms

Toggle sidebar
bg1
Key definitions:
A binary relation R for a set S is a set of SxS or R⊆ SxS
1) For example S=N (natural numbers) R is a divisor of 3 is a divisor of 6, 3R6
2) < for real numbers R
3 is less than 6, 3<6
A relation is
• reflexive if aRa for all a ∈ S
• Symmetric if aRb <=> bRa
• Transitive if aRb and bRc => aRc
Reflexive Symmetric Transitive
Is a divisor of Yes No Yes
< No No Yes
≤ Yes N o Yes
Assume all the undergraduate students have only one advisor, sharing the same advisor is a binary
relation defined on the set of students
Sharing the same advisor
Reflexive? Yes
Symmetric? Yes
Transitive? Yes
We call a reflexive, symmetric, and transitive relation an equivalence relation. If we have an
equivalence relation we could “partition” the set into a group of subsets such that
S1 ∪ S2.....∪ Sn=S
Si ∩ Sj={ Si if i=j for all (i,j) ∈ [1,n] } and ∅ otherwise
for example
Susan → Dr. Wang
Mike → Dr. Smith
Tom e → Dr. Singh
John → Dr. Smith
Susan Tome
John Mike
pf3
pf4

Partial preview of the text

Download Binary Relations and Equivalence Relations: Definitions and Disjoint Sets - Prof. Jun Huan and more Study notes Data Structures and Algorithms in PDF only on Docsity!

Key definitions:

A binary relation R for a set S is a set of SxS or R⊆ SxS

  1. For example S=N (natural numbers) R is a divisor of 3 is a divisor of 6, 3R
  2. < for real numbers R 3 is less than 6, 3<

A relation is

  • reflexive if aRa for all a ∈ S
  • Symmetric if aRb <=> bRa
  • Transitive if aRb and bRc => aRc

Reflexive Symmetric Transitive Is a divisor of Yes No Yes < No No Yes

≤ Yes^ No^ Yes

Assume all the undergraduate students have only one advisor, sharing the same advisor is a binary relation defined on the set of students

Sharing the same advisor Reflexive? Yes Symmetric? Yes Transitive? Yes

We call a reflexive, symmetric, and transitive relation an equivalence relation. If we have an equivalence relation we could “partition” the set into a group of subsets such that

S1 ∪ S2.....∪ Sn=S

Si ∩ Sj={ Si if i=j for all (i,j) ∈ [1,n] } and ∅ otherwise

for example Susan → Dr. Wang Mike → Dr. Smith Tome → Dr. Singh John → Dr. Smith

Susan John^ Mike Tome

Disjoint set is a data structure for equivalence relation between two operations:

  1. find returns a unique ID such that find(x)=find(y) if and only if x and y belong to the same class
  2. Union merges two classes. For the time being lets assume that the elements are called 0,1,2,3,....k k  N

Design options

Hash table (or look up table)

Find O(1) Union O(n)

Tree representation

merge

gives

merge

Gives

union (0,3)

or

union (1,3)

Nothing