Presentation is loading. Please wait.

Presentation is loading. Please wait.

SCIENCE ON FRIDAYS.

Similar presentations


Presentation on theme: "SCIENCE ON FRIDAYS."— Presentation transcript:

1 SCIENCE ON FRIDAYS

2 WHAT IS AN ALGORITHM? Algorithms should be written on paper to be shared and reviewed. You should not be writing any code, nor should you develop algorithms "in your heads."

3

4 Algorithm: Calling a friend on the telephone
Input: The telephone number of your friend. Output: None Steps: Pick up the phone and listen for a dial tone Press each digit of the phone number on the phone If busy, hang up phone, wait 5 minutes, jump to step 2 If no one answers, leave a message then hang up If no answering machine, hang up and wait 2 hours, then jump to step 2 Talk to friend Hang up phone Assumptions: Step 1 assumes that you live alone and no one else could be on the phone. The algorithm assumes the existence of a working phone and active service. The algorithm assumes you are not deaf or mute. The algorithm assumes a normal corded phone.

5 Algorithm execution This is an example of an algorithm for sorting cards with colors on them into piles of the same color: Pick up all of the cards. Pick a card from your hand and look at the color of the card. If there is already a pile of cards of that color, put this card on that pile. If there is no pile of cards of that color, make a new pile of just this card color. If there is still a card in your hand, go back to the second step. If there is not still a card in your hand, then the cards are sorted. You are done.

6 Let’s do an Algorithm. One you can eat
Let’s do an Algorithm. One you can eat. I will be your “computer” and follow exactly each step of your algorithm and I will also be the “stupid” computer I talked about. Use the paper given you and don’t leave anything out

7 Here is an example of a algorithm that will get you a peanut butter and jelly sandwich.
Step 1: Gather Your Ingredients for the Sandwich. ... Step 2: Put Gloves on (optional) ... Step 3: Pull Out Two Slices of Bread and put on plate. ... Step 4: Open Peanut Butter and Jelly. … Step 5 Pick up butter knife. ... Step 6: Spread the Peanut Butter Onto One Slice of Bread. ... Step 7: Spread the Jelly Onto the Other Slice of Bread. ... Step 8: Combine the Two Slices. Step 9: Say: Enjoy

8 Programming is a process and errors are expected
Programming is a process and errors are expected. It is an act of repeating a process, to generate a sequence of outcomes, with the aim of approaching a desired goal, target or result (making a PBJ sandwich). Debugging is the routine process of locating and removing computer program bugs, errors or abnormalities, which is handled by software programmers via debugging tools. Debugging checks, detects and corrects errors or bugs to allow proper program operation according to set specifications. You will "debug" your algorithms and fix all errors and ambiguities. Changes should be made on paper.

9

10

11


Download ppt "SCIENCE ON FRIDAYS."

Similar presentations


Ads by Google