11.07.2015 Views

Data Structures and Algorithm Analysis - Computer Science at ...

Data Structures and Algorithm Analysis - Computer Science at ...

Data Structures and Algorithm Analysis - Computer Science at ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

26 Chap. 2 M<strong>at</strong>hem<strong>at</strong>ical Preliminaries2. if a = b then b = a, <strong>and</strong>3. if a = b <strong>and</strong> b = c, then a = c.Of course, for distinct integers a, b, <strong>and</strong> c there are never cases wherea = b, b = a, or b = c. So the claims th<strong>at</strong> = is symmetric <strong>and</strong> transitive arevacuously true (there are never examples in the rel<strong>at</strong>ion where these eventsoccur). But because the requirements for symmetry <strong>and</strong> transitivity are notviol<strong>at</strong>ed, the rel<strong>at</strong>ion is symmetric <strong>and</strong> transitive.Example 2.2 If we clarify the definition of sibling to mean th<strong>at</strong> a personis a sibling of him- or herself, then the sibling rel<strong>at</strong>ion is an equivalencerel<strong>at</strong>ion th<strong>at</strong> partitions the set of people.Example 2.3 We can use the modulus function (defined in the next section)to define an equivalence rel<strong>at</strong>ion. For the set of integers, use the modulusfunction to define a binary rel<strong>at</strong>ion such th<strong>at</strong> two numbers x <strong>and</strong> y arein the rel<strong>at</strong>ion if <strong>and</strong> only if x mod m = y mod m. Thus, for m = 4,〈1, 5〉 is in the rel<strong>at</strong>ion because 1 mod 4 = 5 mod 4. We see th<strong>at</strong> modulusused in this way defines an equivalence rel<strong>at</strong>ion on the integers, <strong>and</strong> this rel<strong>at</strong>ioncan be used to partition the integers into m equivalence classes. Thisrel<strong>at</strong>ion is an equivalence rel<strong>at</strong>ion because1. x mod m = x mod m for all x;2. if x mod m = y mod m, then y mod m = x mod m; <strong>and</strong>3. if x mod m = y mod m <strong>and</strong> y mod m = z mod m, then x modm = z mod m.A binary rel<strong>at</strong>ion is called a partial order if it is antisymmetric <strong>and</strong> transitive. 2The set on which the partial order is defined is called a partially ordered set or aposet. Elements x <strong>and</strong> y of a set are comparable under a given rel<strong>at</strong>ion if eitherxRy or yRx. If every pair of distinct elements in a partial order are comparable,then the order is called a total order or linear order.Example 2.4 For the integers, rel<strong>at</strong>ions < <strong>and</strong> ≤ define partial orders.Oper<strong>at</strong>ion < is a total order because, for every pair of integers x <strong>and</strong> y suchth<strong>at</strong> x ≠ y, either x < y or y < x. Likewise, ≤ is a total order because, forevery pair of integers x <strong>and</strong> y such th<strong>at</strong> x ≠ y, either x ≤ y or y ≤ x.2 Not all authors use this definition for partial order. I have seen <strong>at</strong> least three significantly differentdefinitions in the liter<strong>at</strong>ure. I have selected the one th<strong>at</strong> lets < <strong>and</strong> ≤ both define partial orders on theintegers, because this seems the most n<strong>at</strong>ural to me.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!