SlideShare ist ein Scribd-Unternehmen logo
1 von 20
Algorithm
What is an algorithm?
“A set of rules to be
followed in problem
solving 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 tbsp peanut butter   followed in problem
•   2 tsp strawberry jam   solving operations.”
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.”
Input                Algorithm   Output
•   2 slices bread

•   1 tbsp peanut butter

•   2 tsp strawberry jam
Selena & Michelle’s
  PBJ algorithm
How 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 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 "--"
# (c) Barbara Shaurette

def 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()
Your algorithms
Example: Get from
the 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 my
  house.
“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.
All get you to where
  you need to go.

Weitere ähnliche Inhalte

Was ist angesagt?

Cpu presentation
Cpu presentationCpu presentation
Cpu presentation
Harry Singh
 
Lesson 1 data processing
Lesson 1   data processing Lesson 1   data processing
Lesson 1 data processing
guevarra_2000
 

Was ist angesagt? (20)

Introduction to Computer Science
Introduction to Computer ScienceIntroduction to Computer Science
Introduction to Computer Science
 
chapter 1 peter norton introduction to computers
chapter 1 peter norton introduction to computerschapter 1 peter norton introduction to computers
chapter 1 peter norton introduction to computers
 
Cpu ppt cse
Cpu ppt cseCpu ppt cse
Cpu ppt cse
 
Round Robin Algorithm.pptx
Round Robin Algorithm.pptxRound Robin Algorithm.pptx
Round Robin Algorithm.pptx
 
Basic+machine+organization
Basic+machine+organizationBasic+machine+organization
Basic+machine+organization
 
Cpu presentation
Cpu presentationCpu presentation
Cpu presentation
 
Computer System Organization
Computer System OrganizationComputer System Organization
Computer System Organization
 
Lesson 1 data processing
Lesson 1   data processing Lesson 1   data processing
Lesson 1 data processing
 
What is algorithm
What is algorithmWhat is algorithm
What is algorithm
 
Presentation on Programming Languages.
Presentation on Programming Languages.Presentation on Programming Languages.
Presentation on Programming Languages.
 
CS4109 Computer System Architecture
CS4109 Computer System ArchitectureCS4109 Computer System Architecture
CS4109 Computer System Architecture
 
Computer architecture
Computer architectureComputer architecture
Computer architecture
 
Algorithms and Flowcharts
Algorithms and FlowchartsAlgorithms and Flowcharts
Algorithms and Flowcharts
 
Algorithm
AlgorithmAlgorithm
Algorithm
 
COMPUTER ORGANIZATION AND ARCHITECTURE
COMPUTER ORGANIZATION AND ARCHITECTURECOMPUTER ORGANIZATION AND ARCHITECTURE
COMPUTER ORGANIZATION AND ARCHITECTURE
 
Predicate logic
 Predicate logic Predicate logic
Predicate logic
 
Chapter1 introduction to computer systems
Chapter1 introduction to computer systemsChapter1 introduction to computer systems
Chapter1 introduction to computer systems
 
Multicore Computers
Multicore ComputersMulticore Computers
Multicore Computers
 
Artificial intelligence cs607 handouts lecture 11 - 45
Artificial intelligence   cs607 handouts lecture 11 - 45Artificial intelligence   cs607 handouts lecture 11 - 45
Artificial intelligence cs607 handouts lecture 11 - 45
 
Intro Ch 06 B
Intro Ch 06 BIntro Ch 06 B
Intro Ch 06 B
 

Andere mochten auch

Writing Chapters 1, 2, 3 of the Capstone Project Proposal Manuscript
Writing Chapters 1, 2, 3 of the Capstone Project Proposal ManuscriptWriting Chapters 1, 2, 3 of the Capstone Project Proposal Manuscript
Writing Chapters 1, 2, 3 of the Capstone Project Proposal Manuscript
Sheryl Satorre
 
O que aconteceu com os mundos virtuais no ensino?
O que aconteceu com os mundos virtuais no ensino?O que aconteceu com os mundos virtuais no ensino?
O que aconteceu com os mundos virtuais no ensino?
Neli Maria Mengalli
 
圖說人生哲理
圖說人生哲理圖說人生哲理
圖說人生哲理
nonnon
 
你的桶子有多滿
你的桶子有多滿你的桶子有多滿
你的桶子有多滿
nonnon
 
Baker Wedding Slideshow Review
Baker Wedding Slideshow ReviewBaker Wedding Slideshow Review
Baker Wedding Slideshow Review
mattwjohnson
 
Even Start Flipbook
Even Start FlipbookEven Start Flipbook
Even Start Flipbook
kkibbey
 
Data Mining Protein Structures' Topological Properties to Enhance Contact Ma...
Data Mining Protein Structures' Topological Properties  to Enhance Contact Ma...Data Mining Protein Structures' Topological Properties  to Enhance Contact Ma...
Data Mining Protein Structures' Topological Properties to Enhance Contact Ma...
jaumebp
 
La3 Computer Network
La3 Computer NetworkLa3 Computer Network
La3 Computer Network
Cma Mohd
 
Johannes Lars
Johannes LarsJohannes Lars
Johannes Lars
eka
 

Andere mochten auch (20)

Making Software Communities
Making Software CommunitiesMaking Software Communities
Making Software Communities
 
Introduction to Recipes for Agile Governance in the Enterprise (RAGE)
Introduction to Recipes for Agile Governance in the Enterprise (RAGE)Introduction to Recipes for Agile Governance in the Enterprise (RAGE)
Introduction to Recipes for Agile Governance in the Enterprise (RAGE)
 
Writing Chapters 1, 2, 3 of the Capstone Project Proposal Manuscript
Writing Chapters 1, 2, 3 of the Capstone Project Proposal ManuscriptWriting Chapters 1, 2, 3 of the Capstone Project Proposal Manuscript
Writing Chapters 1, 2, 3 of the Capstone Project Proposal Manuscript
 
Flex et Php Afup
Flex et Php AfupFlex et Php Afup
Flex et Php Afup
 
O que aconteceu com os mundos virtuais no ensino?
O que aconteceu com os mundos virtuais no ensino?O que aconteceu com os mundos virtuais no ensino?
O que aconteceu com os mundos virtuais no ensino?
 
Ch01
Ch01Ch01
Ch01
 
圖說人生哲理
圖說人生哲理圖說人生哲理
圖說人生哲理
 
Spring 3 - An Introduction
Spring 3 - An IntroductionSpring 3 - An Introduction
Spring 3 - An Introduction
 
Class Project Pxgt 6110
Class Project Pxgt 6110Class Project Pxgt 6110
Class Project Pxgt 6110
 
你的桶子有多滿
你的桶子有多滿你的桶子有多滿
你的桶子有多滿
 
Baker Wedding Slideshow Review
Baker Wedding Slideshow ReviewBaker Wedding Slideshow Review
Baker Wedding Slideshow Review
 
Even Start Flipbook
Even Start FlipbookEven Start Flipbook
Even Start Flipbook
 
Data Mining Protein Structures' Topological Properties to Enhance Contact Ma...
Data Mining Protein Structures' Topological Properties  to Enhance Contact Ma...Data Mining Protein Structures' Topological Properties  to Enhance Contact Ma...
Data Mining Protein Structures' Topological Properties to Enhance Contact Ma...
 
Lorelle at WordCamp 2008 - 260 Ways to Break WordPress
Lorelle at WordCamp 2008 - 260 Ways to Break WordPressLorelle at WordCamp 2008 - 260 Ways to Break WordPress
Lorelle at WordCamp 2008 - 260 Ways to Break WordPress
 
4 T
4  T4  T
4 T
 
6. open innov conclusions
6. open innov conclusions6. open innov conclusions
6. open innov conclusions
 
La3 Computer Network
La3 Computer NetworkLa3 Computer Network
La3 Computer Network
 
I M S Rubashkin
I M S RubashkinI M S Rubashkin
I M S Rubashkin
 
Johannes Lars
Johannes LarsJohannes Lars
Johannes Lars
 
Hide you file behind a picture
Hide you file behind a pictureHide you file behind a picture
Hide you file behind a picture
 

Mehr von Selena Deckelmann

While we're here, let's fix computer science education
While we're here, let's fix computer science educationWhile we're here, let's fix computer science education
While we're here, let's fix computer science education
Selena Deckelmann
 
Mistakes were made - LCA 2012
Mistakes were made - LCA 2012Mistakes were made - LCA 2012
Mistakes were made - LCA 2012
Selena Deckelmann
 
Harder, better, faster, stronger: PostgreSQL 9.1
Harder, better, faster, stronger: PostgreSQL 9.1Harder, better, faster, stronger: PostgreSQL 9.1
Harder, better, faster, stronger: PostgreSQL 9.1
Selena Deckelmann
 
Own it: working with a changing open source community
Own it: working with a changing open source communityOwn it: working with a changing open source community
Own it: working with a changing open source community
Selena Deckelmann
 
Managing terabytes: When Postgres gets big
Managing terabytes: When Postgres gets bigManaging terabytes: When Postgres gets big
Managing terabytes: When Postgres gets big
Selena Deckelmann
 

Mehr von Selena Deckelmann (20)

While we're here, let's fix computer science education
While we're here, let's fix computer science educationWhile we're here, let's fix computer science education
While we're here, let's fix computer science education
 
Hire the right way
Hire the right wayHire the right way
Hire the right way
 
Mistakes were made - LCA 2012
Mistakes were made - LCA 2012Mistakes were made - LCA 2012
Mistakes were made - LCA 2012
 
Pg92 HA, LCA 2012, Ballarat
Pg92 HA, LCA 2012, BallaratPg92 HA, LCA 2012, Ballarat
Pg92 HA, LCA 2012, Ballarat
 
Managing terabytes
Managing terabytesManaging terabytes
Managing terabytes
 
Mistakes were made
Mistakes were madeMistakes were made
Mistakes were made
 
Postgres needs an aircraft carrier
Postgres needs an aircraft carrierPostgres needs an aircraft carrier
Postgres needs an aircraft carrier
 
Mistakes were made
Mistakes were madeMistakes were made
Mistakes were made
 
Harder, better, faster, stronger: PostgreSQL 9.1
Harder, better, faster, stronger: PostgreSQL 9.1Harder, better, faster, stronger: PostgreSQL 9.1
Harder, better, faster, stronger: PostgreSQL 9.1
 
How to ask for money
How to ask for moneyHow to ask for money
How to ask for money
 
Letters from the open source trenches - Postgres community
Letters from the open source trenches - Postgres communityLetters from the open source trenches - Postgres community
Letters from the open source trenches - Postgres community
 
Own it: working with a changing open source community
Own it: working with a changing open source communityOwn it: working with a changing open source community
Own it: working with a changing open source community
 
Managing terabytes: When Postgres gets big
Managing terabytes: When Postgres gets bigManaging terabytes: When Postgres gets big
Managing terabytes: When Postgres gets big
 
Managing terabytes: When PostgreSQL gets big
Managing terabytes: When PostgreSQL gets bigManaging terabytes: When PostgreSQL gets big
Managing terabytes: When PostgreSQL gets big
 
Pdxpugday2010 pg90
Pdxpugday2010 pg90Pdxpugday2010 pg90
Pdxpugday2010 pg90
 
Illustrated buffer cache
Illustrated buffer cacheIllustrated buffer cache
Illustrated buffer cache
 
Bucardo
BucardoBucardo
Bucardo
 
How a bunch of normal people Used Technology To Repair a Rigged Election
How a bunch of normal people Used Technology To Repair a Rigged ElectionHow a bunch of normal people Used Technology To Repair a Rigged Election
How a bunch of normal people Used Technology To Repair a Rigged Election
 
Open Source Bridge Opening Day
Open Source Bridge Opening DayOpen Source Bridge Opening Day
Open Source Bridge Opening Day
 
What Assumptions Make: Filesystem I/O from a database perspective
What Assumptions Make: Filesystem I/O from a database perspectiveWhat Assumptions Make: Filesystem I/O from a database perspective
What Assumptions Make: Filesystem I/O from a database perspective
 

Kürzlich hochgeladen

Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...
Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...
Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...
amitlee9823
 
Insurers' journeys to build a mastery in the IoT usage
Insurers' journeys to build a mastery in the IoT usageInsurers' journeys to build a mastery in the IoT usage
Insurers' journeys to build a mastery in the IoT usage
Matteo Carbone
 
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...
Dipal Arora
 
FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756
dollysharma2066
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
dollysharma2066
 

Kürzlich hochgeladen (20)

Dr. Admir Softic_ presentation_Green Club_ENG.pdf
Dr. Admir Softic_ presentation_Green Club_ENG.pdfDr. Admir Softic_ presentation_Green Club_ENG.pdf
Dr. Admir Softic_ presentation_Green Club_ENG.pdf
 
It will be International Nurses' Day on 12 May
It will be International Nurses' Day on 12 MayIt will be International Nurses' Day on 12 May
It will be International Nurses' Day on 12 May
 
The Coffee Bean & Tea Leaf(CBTL), Business strategy case study
The Coffee Bean & Tea Leaf(CBTL), Business strategy case studyThe Coffee Bean & Tea Leaf(CBTL), Business strategy case study
The Coffee Bean & Tea Leaf(CBTL), Business strategy case study
 
Monte Carlo simulation : Simulation using MCSM
Monte Carlo simulation : Simulation using MCSMMonte Carlo simulation : Simulation using MCSM
Monte Carlo simulation : Simulation using MCSM
 
Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...
Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...
Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...
 
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best ServicesMysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
 
Insurers' journeys to build a mastery in the IoT usage
Insurers' journeys to build a mastery in the IoT usageInsurers' journeys to build a mastery in the IoT usage
Insurers' journeys to build a mastery in the IoT usage
 
Yaroslav Rozhankivskyy: Три складові і три передумови максимальної продуктивн...
Yaroslav Rozhankivskyy: Три складові і три передумови максимальної продуктивн...Yaroslav Rozhankivskyy: Три складові і три передумови максимальної продуктивн...
Yaroslav Rozhankivskyy: Три складові і три передумови максимальної продуктивн...
 
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...
 
FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756
 
Value Proposition canvas- Customer needs and pains
Value Proposition canvas- Customer needs and painsValue Proposition canvas- Customer needs and pains
Value Proposition canvas- Customer needs and pains
 
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...
 
Call Girls Pune Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Pune Just Call 9907093804 Top Class Call Girl Service AvailableCall Girls Pune Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Pune Just Call 9907093804 Top Class Call Girl Service Available
 
M.C Lodges -- Guest House in Jhang.
M.C Lodges --  Guest House in Jhang.M.C Lodges --  Guest House in Jhang.
M.C Lodges -- Guest House in Jhang.
 
Famous Olympic Siblings from the 21st Century
Famous Olympic Siblings from the 21st CenturyFamous Olympic Siblings from the 21st Century
Famous Olympic Siblings from the 21st Century
 
KYC-Verified Accounts: Helping Companies Handle Challenging Regulatory Enviro...
KYC-Verified Accounts: Helping Companies Handle Challenging Regulatory Enviro...KYC-Verified Accounts: Helping Companies Handle Challenging Regulatory Enviro...
KYC-Verified Accounts: Helping Companies Handle Challenging Regulatory Enviro...
 
VIP Call Girls In Saharaganj ( Lucknow ) 🔝 8923113531 🔝 Cash Payment (COD) 👒
VIP Call Girls In Saharaganj ( Lucknow  ) 🔝 8923113531 🔝  Cash Payment (COD) 👒VIP Call Girls In Saharaganj ( Lucknow  ) 🔝 8923113531 🔝  Cash Payment (COD) 👒
VIP Call Girls In Saharaganj ( Lucknow ) 🔝 8923113531 🔝 Cash Payment (COD) 👒
 
👉Chandigarh Call Girls 👉9878799926👉Just Call👉Chandigarh Call Girl In Chandiga...
👉Chandigarh Call Girls 👉9878799926👉Just Call👉Chandigarh Call Girl In Chandiga...👉Chandigarh Call Girls 👉9878799926👉Just Call👉Chandigarh Call Girl In Chandiga...
👉Chandigarh Call Girls 👉9878799926👉Just Call👉Chandigarh Call Girl In Chandiga...
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
Monthly Social Media Update April 2024 pptx.pptx
Monthly Social Media Update April 2024 pptx.pptxMonthly Social Media Update April 2024 pptx.pptx
Monthly Social Media Update April 2024 pptx.pptx
 

Algorithms are Recipes

  • 2. What is an algorithm?
  • 3. “A set of rules to be followed in problem solving operations.”
  • 5. Input Algorithm Output
  • 6. Input Algorithm Output “A set of rules to be followed in problem solving operations.”
  • 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. 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. Input Algorithm Output • 2 slices bread • 1 tbsp peanut butter • 2 tsp strawberry jam
  • 10. Selena & Michelle’s PBJ algorithm How many steps do you think it will take?
  • 11. There’s more than one way to do it.
  • 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. # (c) Barbara Shaurette def 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()
  • 15. Example: Get from the airport to home.
  • 16. “The taxi algorithm” • Go to the taxi stand. • Get in a taxi. • Give the driver my address.
  • 17. “The call-me algorithm” • When your plane arrives, call my cell phone. • Meet me outside baggage claim.
  • 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. “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. All get you to where you need to go.

Hinweis der Redaktion

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n