Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 2

Advanced Discrete Homework

January 31, 2008

1. A wise but short-sighted toad is looking for the Truth. The toad sees no more than
1 meter away while the Truth is located in the plane at distance at most D meters
from the toad. The toad can make jumps, each of length at most 1 meter and after
each jump she knows if she came closer to the Truth or not. Devise a strategy by
which the toad can find the Truth in as few hops as you can manage.

Suppose the following are considered atomic operations:


(x,y)  x+y; (x,y)  x-y; (x,y)  x=y; (x,y)  x<y

Use these operations to create an algorithm (i.e., a clear, unambiguous process) to


calculate each of the following in as few operations as you can manage.

If you can, say how many operations each algorithm would take (of course, this will
likely depend on the input numbers, so you can do it in terms of those).

2. The product of two integers, n, and m.


3. The integer quotient and remainder of n / m.
4. Whether a given integer, n, is prime.
5. The GCD of two given integers, x and y.

Advanced Discrete Homework


January 31, 2008

1. A wise but short-sighted toad is looking for the Truth. The toad sees no more than
1 meter away while the Truth is located in the plane at distance at most D meters
from the toad. The toad can make jumps, each of length at most 1 meter and after
each jump she knows if she came closer to the Truth or not. Devise a strategy by
which the toad can find the Truth in as few hops as you can manage.

Suppose the following are considered atomic operations:


(x,y)  x+y; (x,y)  x-y; (x,y)  x=y; (x,y)  x<y

Use these operations to create an algorithm (i.e., a clear, unambiguous process) to


calculate each of the following in as few operations as you can manage.

If you can, say how many operations each algorithm would take (of course, this will
likely depend on the input numbers, so you can do it in terms of those).

2. The product of two integers, n, and m.


3. The integer quotient and remainder of n / m.
4. Whether a given integer, n, is prime.
5. The GCD of two given integers, x and y.

You might also like