| Overall Reading | |
|---|---|
| Brookshear: | Ch. 0.1, 4.1-4.2 |
Outline:
We are given directions all of the time: cooking, electronics,
music.
Creating a "To Do" list such as
Pick up groceries Pay the bills Practice piano Prepare a lectureIs not the same as defining an algorithm
An algorithm for organizing my mail:
For each piece of mail received,
* If it is a bill, pay it
* If it is an advertisement, throw it away.
* If it is addressed to my wife, put it in pile "Susan"
* If it is a postcard, place it on the refrigerator door
* If it is in an oversized envelope put it on the desk
If following this algorithm, what am I supposed to do with a postcard,
addressed to my wife, from Domino's Pizza?
Algorithm for breaking the world record for the high-jump:
1. Set the bar at 2.46 meters 2. Take 30 paces backwards and face the bar 3. Run as fast as you can 4. Jump over the bar, without knocking it down 5. Celebrate by dancingAlgorithm for a secure cryptography scheme:
1. Let X = the largest possible prime number 2. Let Y = the second largest prime number 3. Let P = X*Y be your "public key" for encryption
Shampoo instructions:
1. Wet hair 2. Lather shampoo 3. Rinse 4. Repeat
Note: Do not confuse lack of detail in the representation with inherent ambiguity in the algorithm.
When creating a system of primitives, must define:
When communicating between humans, we want to be precise, but not overly structured. We will give more examples later, but what we imagine is being able to describe algorithms usning notation such as:
if (sales have decreased)
then (lower the price by 5%)
else (raise the price by 2%)
Description: This algorithm assumes that its input consists of two positive integers and proceeds to compute the greatest common divisor of these two values.
Procedure:
Example: GCD(48,18)
We all learned how to do addition in elementary school. At this point, we seem to know the process to follow by heart.
Example: What is 3587+206?
What is that process? Can you formalize the algorithm.
Please note: Do not simply walk someone through this particular example; explain the general process.
Note also: An algorithm is the process. In describing it, you do not need to explain why it works, simply the process itself.
Here is my attempt.
Is process for calculating 8/7 terminating?