Discrete Mathematics with Graph Theory (3rd Edition) 222

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

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

View Full Document Right Arrow Icon
220 Step 1: set F = 0; Step 2: for i = 1 to n, if x ~ ai and F = 0, output x and set F = 1; output ai. Step 3: if F = 0, output x. Solutions to Exercises The variable F introduced here is ajlag, whose purpose is to tell us whether or not x has been output. At the end of the loop in Step 2, if x has not been output (that is, x is larger than all the ai's), then we will know this, because F will not have changed from its initial value of 0; hence, we must output x as the final element. Note that the "and" in Step 2 is the logical "and" introduced in Section 0.1. We output x and set F = 1 only if both x ~ ai and F = 0 are true. 13. The idea is to test each integer x between 0 and n - 1 for the possibility n I (ax - b). After we have checked x = n -1, however, we need a way to ascertain whether or not any solutions have been found. For this purpose, we introduce a flag F which is set initially to 0 and, if a solution to ax == b (mod n) is found, reset to 1. If the value of F at the end is still 0, we know there are no solutions. Here is an
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/08/2010 for the course MATH discrete m taught by Professor Any during the Summer '10 term at FSU.

Ask a homework question - tutors are online