Algorithm
What is an algorithm?
“A set of rules to befollowed in problemsolving operations.”
or “A Recipe”
Input   Algorithm   Output
Input   Algorithm               Output        “A set of rules to be        followed in problem        solving operations.”
Input                Algorithm               Output•   2 slices bread                           “A set of rules to be•   1...
Input                Algorithm               Output•   2 slices bread                           “A set of rules to be•   1...
Input                Algorithm   Output•   2 slices bread•   1 tbsp peanut butter•   2 tsp strawberry jam
Selena & Michelle’s  PBJ algorithmHow many steps do you think it will            take?
There’s more than one way to do it.
"""(C) Gerold Penz)Python can be simple, too :-)"""for quant in range(99, 0, -1):  if quant > 1:    print quant, "bottles ...
# (c) Barbara Shaurettedef bottles(): for i in reversed(range(100)):  if i > 0:    b = "bottles"    if i == 1: b = "bottle...
Your algorithms
Example: Get fromthe airport to home.
“The taxi algorithm”• Go to the taxi stand.• Get in a taxi.• Give the driver my address.
“The call-me         algorithm”• When your plane arrives, call my cell  phone.• Meet me outside baggage claim.
“The rent-a-car       algorithm”• Take the shuttle to the rental car place.• Rent a car.• Follow the directions to get to ...
“The bus algorithm”• Outside baggage claim, catch bus  number 70.• Transfer to bus 14 on Main Street.• Get off on Elm stre...
All get you to where  you need to go.
Upcoming SlideShare
Loading in...5
×

Algorithms are Recipes

1,267
-1

Published on

Introduction to what algorithms are, and how to create them for real life

Published in: Business, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,267
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
16
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Algorithms are Recipes

    1. 1. Algorithm
    2. 2. What is an algorithm?
    3. 3. “A set of rules to befollowed in problemsolving operations.”
    4. 4. or “A Recipe”
    5. 5. Input Algorithm Output
    6. 6. Input Algorithm Output “A set of rules to be followed in problem solving operations.”
    7. 7. Input Algorithm Output• 2 slices bread “A set of rules to be• 1 tbsp peanut butter followed in problem• 2 tsp strawberry jam solving operations.”
    8. 8. Input Algorithm Output• 2 slices bread “A set of rules to be• 1 tbsp peanut butter followed in problem• 2 tsp strawberry jam solving operations.”
    9. 9. Input Algorithm Output• 2 slices bread• 1 tbsp peanut butter• 2 tsp strawberry jam
    10. 10. Selena & Michelle’s PBJ algorithmHow many steps do you think it will take?
    11. 11. There’s more than one way to do it.
    12. 12. """(C) Gerold Penz)Python can be simple, too :-)"""for quant in range(99, 0, -1): if quant > 1: print quant, "bottles of beer on the wall,", quant, "bottles of beer." if quant > 2: suffix = str(quant - 1) + " bottles of beer on the wall." else: suffix = "1 bottle of beer on the wall." elif quant == 1: print "1 bottle of beer on the wall, 1 bottle of beer." suffix = "no more beer on the wall!" print "Take one down, pass it around,", suffix print "--"
    13. 13. # (c) Barbara Shaurettedef bottles(): for i in reversed(range(100)): if i > 0: b = "bottles" if i == 1: b = "bottle" print i, b, "of beer on the wall,", i, b, "of beer" print "Take one down, pass it around,", i-1, "bottles of beer on the wallnr"bottles()
    14. 14. Your algorithms
    15. 15. Example: Get fromthe airport to home.
    16. 16. “The taxi algorithm”• Go to the taxi stand.• Get in a taxi.• Give the driver my address.
    17. 17. “The call-me algorithm”• When your plane arrives, call my cell phone.• Meet me outside baggage claim.
    18. 18. “The rent-a-car algorithm”• Take the shuttle to the rental car place.• Rent a car.• Follow the directions to get to my house.
    19. 19. “The bus algorithm”• Outside baggage claim, catch bus number 70.• Transfer to bus 14 on Main Street.• Get off on Elm street.• Walk two blocks north to my house.
    20. 20. All get you to where you need to go.
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×