Discrete Mathematics with Graph Theory (3rd Edition) 243

Discrete Mathematics with Graph Theory (3rd Edition) 243 -...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Chapter 8 Step 3: if F = 0, output "reflexive"; otherwise, output "not reflexive". The algorithm requires at most t comparisons. 241 (b) We set up a matrix A = [aij] whose (i,j) entry is a 1 if and only if (i,j) En, and otherwise O. Step 1: for i = 1 to t for j = 1 to t set aij = o. Step 2: For i = 1 to t, set the (ai, b i ) entry of A equal to l. Step 3: Set F = 0 and i = l. Step 4: while F = 0 and i < t, for j = i to t if aij #- aji set F = 1; replace i by i + l. end while Step 5: If F = 0, output "symmetric" and stop; otherwise output "not symmetric" and stop. When i = 1, the loop inside Step 4 requires t comparisons. When i = 2, the loop requires t - 1 comparisons, and so on. The number of comparisons is at most t+ (t-1) + ... +2+ 1 = ~t(t+ 1), so the algorithm is O(t 2 ). (c) We set up a matrix A whose (i,j) entry is a 1 if and only if (i,j) E n, and otherwise O. The relation fails to be antisymmetric if and only if some aij = 1 = aji with i #- j, and this occurs if and only if
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.
Ask a homework question - tutors are online