Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Algorithms are Recipes

3,092 views

Published on

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

Published in: Business, Technology
  • Login to see the comments

  • Be the first to like this

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.

×