You are on page 1of 3

Q.

1 The Principle of Inclusion and Exclusion (PIE) is a counting technique


that computes the number of elements that satisfy at least one of several
properties while guaranteeing that elements satisfying more than one
property are not counted twice.

An underlying idea behind PIE is that summing the number of elements


that satisfy at least one of two categories and subtracting the overlap
prevents double counting. For instance, the number of people that have at
least one cat or at least one dog can be found by taking the number of
people who own a cat, adding the number of people that have a dog, then
subtracting the number of people who have both.

In the case of objects being separated into two (possibly disjoint) sets,
the principle of inclusion and exclusion states

(AUB) = A + B – (A B)

Q.2 Warshall Algoritm:


Q.2 A binary relation between two sets X and Y (or between the elements
of X and Y ) is a subset of X × Y — i.e., is a set of ordered pairs (x, y) ∈ X ×
Y . If R is a relation between X and Y (i.e., if R ⊆ X × Y ), we often write
xRy instead of (x, y) ∈ R. We write Rc for the complement of R — i.e., xRc
y if and only if (x, y) ∈/ R. If X and Y are the same set, so that the relation
R is a subset of X × X, we say that R is a relation on X.

reflexive if ∀x ∈ X : xRx; (b) symmetric if ∀x, x0 ∈ X : x 0Rx ⇒ xRx0 ; (c)


transitive if ∀x, x0 , x00 ∈ X : [x 00Rx0 & x 0Rx] ⇒ x 00Rx; (d) complete if
∀x, x0 ∈ X : xRx0 or x 0Rx; (e) antisymmetric if ∀x, x0 ∈ X : [x 0Rx & xRx0
] ⇒ x = x 0 (f) asymmetric if ∀x, x0 ∈ X : [x 0Rx ⇒ xRcx 0 ] (g) irreflexive if
∀x ∈ X : xRcx.
Example.

X is a set of people. Each of the following is a binary relation on X:

(a) xNy : x lives next door to y. N would typically be symmetric, irreflexive,


and not transitive.

(b) xBy : x lives on the same block as y. B would typically be reflexive,


symmetric, and transitive.

(c) xSy : x is a sister of y. S would typically be irreflexive, not symmetric


(unless all elements of X are female), and not transitive.

(d) xAy : x is an ancestor of y. A would typically be irreflexive,


asymmetric, and transitive — a strict preorder, as we’ll define shortly.

(e) xDy : x is a daughter of y. D would be irreflexive, asymmetric, and not


transitive.

You might also like