SlideShare uma empresa Scribd logo
1 de 37
VISUAL PROBLEM SOLVING
Computer
Science
20S
with Mr. Wachs – Thursday, September 16, 2021
Algorithm
Algorithm
Flowcharts have applications in
many areas other than
computer solutions
For example, in how-to-build-it
instructions and recipes
An algorithm is a step-by-
step procedure for solving a
problem
Algorithm (cont’d)
An algorithm for baking a chocolate
cake is the chocolate cake recipe
An algorithm for repairing your
Mustang carburetor is the instructions
in the shop manual
A flowchart is a “picture” of the
algorithm
If it is done well, it is like a road map,
and the path to the solution will be
smooth
Algorithm (cont’d)
A computer program is a set of
instructions that tells a computer to
solve a problem in a step-by-step
manner
The program is written from a logic
representation
The model we employ when using the
computer to find a solution is first the
algorithm and then the “picture”
A flowchart
Algorithm (cont’d)
From the flowchart we form a
computer program, which we
use to arrive at the solution
We can check the solution either
by hand or by running the
program
Here are two analogous stages to
problem solving (with the
computer and without)
Algorithm (cont’d)
Without Computer With Computer
1. What is the problem? Same
2. Make a model of the problem Develop an algorithm
3. Analyze the model Use a flowchart?
4. Find the solution Write a computer program
5. Check the solution Run the program
Problem Solving…
Continuing with our analysis of
higher-level problem solving
techniques, today we will examine
the concept of Top Down Design
Problem solving often involves
breaking a problem down into
smaller more manageable parts
Then deal with each part
individually
Top Down Design
This method is well suited to
problem solving
It allows us to start with general
steps and elaborate on them
until the problem is solved
The process of making the steps
more and more specific in top
down design is called stepwise
refinement
Let’s Try it…
(1.) The problem:
Building a barn
This is a big
project, so we
break the project
down into smaller
steps
Top Down Design (cont’d)
Let’s Build
a Barn
Build
Foundation
Build
Walls
Build
Roof
Now continue with the step wise
refinement, breaking down each
section again
Top Down Design (cont’d)
Build
a Barn
Build
Foundation
Build
Walls
Build
Roof
step wise refinement could continue
even more, but you see the pattern
Dig Concrete Framing Paneling Rafters Shingles
Top Down Design (cont’d)
Hierarchy charts do not indicate
the flow of data
But instead illustrate the tasks,
or modules, for each part of the
solution
The only flow of data important
is what should go into and come
out of each module
Another Example…
An ATM machine…
ATM Machine
Get Inputs Give Outputs
Perform all
Calculations
First level hierarchy chart
The ATM example (cont’d)
Second level hierarchy chart for input
Get Inputs
Get Password
Get Transaction
Amount
Get Transaction
Type
The ATM example (cont’d)
Second level hierarchy chart for output
Get Outputs
Print Error
Message
Dispense Cash
Print Balance
The ATM example (cont’d)
Second and third level hierarchy chart for calculations
Perform
Calculations
Handle
Deposits
Handle
Withdrawals
Add amount
to balance
Check
balance
Subtract amount
from balance
Give an error
message
The ATM example (cont’d)
The complete
hierarchy
chart for the
ATM
Perform all
calculations
Handle
Deposits
Handle
Withdrawals
Add amount
to balance
Check
balance
Subtract amount
from balance
Give an error
message
Give
outputs
Print error
message
Print
balance
Dispense
cash
Give
Inputs
Get
password
Get
transaction
Get
amount
ATM
Top Down Design (cont’d)
The use of top down
design, or hierarchy
charts is truly a divide
and conquer method
of problem solving
Logical Representations
A logical representation is some sort
of model that represents processes in
the real world
In some sense, mathematics is a model
that represents the logic of natural
systems
We have already used top down design
diagrams and other logic representations
Now we’ll examine another method
commonly used in computer problem
solving, flowcharts
Flowchart
Symbols
Flowchart Symbols
The common flowchart symbols
Start/Stop – necessary for
every flowchart
Operation – do something
Arrow – shows direction of
flow
Flowchart Symbols (cont’d)
Decision – answer yes
or no
Information in – “read
in”
Information out –
“output box”
Connector – used for
larger flowcharts
Let’s Try it…
(1.) The problem:
How do you
enter a
locked
room?
Solution…
First, list all necessary steps (algorithm)
Do not take anything for granted
Second, put the steps in the correct
order
1. Walk to the room
2. Stop at the door
3. Take keys from pocket
4. Choose correct key
5. Put key in lock
Solution…
6.Turn key
7.Open door
8.Take key out of lock
9.Walk in
Now the corresponding
flowchart
Solution…
START
Take out keys
Walk to room
Stop at door
Choose key
Put in lock
Turn key Open door
Take key out
Walk in
STOP
Another one…
The problem…
You are in a house with a
telephone, a doorbell, and a
alarm clock
You hear one of
them ringing,
what is the
solution
Solution…
START
Listen to the
bell ringing
Is it the
telephone?
Answer the
phone
Is it the
doorbell?
See who is at
the door
Turn off the
alarm
STOP
N Y
Y N
“Decision Symbol”
With this symbol, there is always
one arrow coming in, but two
arrows (the decision) coming out
?
No
Yes
The problem…
Flowchart our ATM
machine
example
from earlier
Solution…
Get password
Is
Password
correct
Get type and amount
Deposit
or
withdraw
Is
Amount <
balance
Add amount
to balance
Subtract from
balance
Give error message
or response
N
N
N
Y
Y
Y
Start
Stop
Last one…
The problem…
Leonardo Fibonacci of Pisa wrote in
1202 about the number of rabbits that
would be found at the end of a year if
we started with a single pair of rabbits
The pair produced one pair of offspring
after the second month
Then they stopped breeding
Each new pair also produced
two more pairs in the same
way then stopped breeding
Problem (cont’d)
The answer to the first year is as follows
Number of
additional pairs
1 1 2 3 5 8 13 21 34 55 89 144
Month 1 2 3 4 5 6 7 8 9 10 11 12
The first 2 months are both 1 (since there
is only one additional pair)
Each month after, is the sum of the 2
months before it
This is know as the Fibonacci sequence
Problem (cont’d)
Looking at it mathematically…
F1 = 1 This translates as “first month (F1) equals one pair”
F2 = 1 This translates as “second month (F2) equals one
additional pair”
F3 = F2 + F1
= 1 + 1
This translates as “third month (F3) equals second month
plus first month”
F4 = F3 + F2
= 2 + 1
= 3
Etc.
There is a definite pattern, and thus we
have found an algorithm to find all the
terms
Start
Let the old
Term equal 0
Let the newest
Term equal 1
Find sum of
Old and new term
Is sum
> 100?
Let old term equal
The newest term
Let the newest
Term equal the sum
Write out
The sum
Stop
Y
N
Solution…
For numbers up to
100
Go on to
Today’s
Assignment

Mais conteúdo relacionado

Semelhante a Visual Problem Solving (Lecture)

Algorithm and flowchart with pseudo code
Algorithm and flowchart with pseudo codeAlgorithm and flowchart with pseudo code
Algorithm and flowchart with pseudo codehamza javed
 
Week1 programming challenges
Week1 programming challengesWeek1 programming challenges
Week1 programming challengesDhanu Srikar
 
Lecture 01-2.ppt
Lecture 01-2.pptLecture 01-2.ppt
Lecture 01-2.pptRaoHamza24
 
Algorithm for computational problematic sit
Algorithm for computational problematic sitAlgorithm for computational problematic sit
Algorithm for computational problematic sitSaurabh846965
 
Std 10 computer chapter 9 Problems and Problem Solving
Std 10 computer chapter 9 Problems and Problem SolvingStd 10 computer chapter 9 Problems and Problem Solving
Std 10 computer chapter 9 Problems and Problem SolvingNuzhat Memon
 
DA lecture 3.pptx
DA lecture 3.pptxDA lecture 3.pptx
DA lecture 3.pptxSayanSen36
 
19IS402_LP1_LM_22-23.pdf
19IS402_LP1_LM_22-23.pdf19IS402_LP1_LM_22-23.pdf
19IS402_LP1_LM_22-23.pdfGOWTHAMR721887
 
Algorithms and how to write an algorithms
Algorithms and how to write an algorithmsAlgorithms and how to write an algorithms
Algorithms and how to write an algorithmsAhmed Nobi
 
Kk20503 1 introduction
Kk20503 1 introductionKk20503 1 introduction
Kk20503 1 introductionLow Ying Hao
 
complexity analysis.pdf
complexity analysis.pdfcomplexity analysis.pdf
complexity analysis.pdfpasinduneshan
 
Pengenalan kepada pengaturcaraan berstruktur
Pengenalan kepada pengaturcaraan berstrukturPengenalan kepada pengaturcaraan berstruktur
Pengenalan kepada pengaturcaraan berstrukturUnit Kediaman Luar Kampus
 
Small Basic Calculator Apps lesson
Small Basic Calculator Apps lessonSmall Basic Calculator Apps lesson
Small Basic Calculator Apps lessonEdujetage
 
Basic Slides on Algorithms and Flowcharts
Basic Slides on Algorithms and FlowchartsBasic Slides on Algorithms and Flowcharts
Basic Slides on Algorithms and Flowchartsmoazwinner
 
Csallner algorithms1
Csallner algorithms1Csallner algorithms1
Csallner algorithms1seshagiri rao
 
Algorithm types performance steps working
Algorithm types performance steps workingAlgorithm types performance steps working
Algorithm types performance steps workingSaurabh846965
 

Semelhante a Visual Problem Solving (Lecture) (20)

Algorithm and flowchart with pseudo code
Algorithm and flowchart with pseudo codeAlgorithm and flowchart with pseudo code
Algorithm and flowchart with pseudo code
 
Week1 programming challenges
Week1 programming challengesWeek1 programming challenges
Week1 programming challenges
 
Lecture 01-2.ppt
Lecture 01-2.pptLecture 01-2.ppt
Lecture 01-2.ppt
 
CC-112-Lec.1.ppsx
CC-112-Lec.1.ppsxCC-112-Lec.1.ppsx
CC-112-Lec.1.ppsx
 
Algorithm for computational problematic sit
Algorithm for computational problematic sitAlgorithm for computational problematic sit
Algorithm for computational problematic sit
 
PPS_Unit 1.pptx
PPS_Unit 1.pptxPPS_Unit 1.pptx
PPS_Unit 1.pptx
 
Std 10 computer chapter 9 Problems and Problem Solving
Std 10 computer chapter 9 Problems and Problem SolvingStd 10 computer chapter 9 Problems and Problem Solving
Std 10 computer chapter 9 Problems and Problem Solving
 
DA lecture 3.pptx
DA lecture 3.pptxDA lecture 3.pptx
DA lecture 3.pptx
 
19IS402_LP1_LM_22-23.pdf
19IS402_LP1_LM_22-23.pdf19IS402_LP1_LM_22-23.pdf
19IS402_LP1_LM_22-23.pdf
 
Algorithms and how to write an algorithms
Algorithms and how to write an algorithmsAlgorithms and how to write an algorithms
Algorithms and how to write an algorithms
 
Kk20503 1 introduction
Kk20503 1 introductionKk20503 1 introduction
Kk20503 1 introduction
 
complexity analysis.pdf
complexity analysis.pdfcomplexity analysis.pdf
complexity analysis.pdf
 
Pengenalan kepada pengaturcaraan berstruktur
Pengenalan kepada pengaturcaraan berstrukturPengenalan kepada pengaturcaraan berstruktur
Pengenalan kepada pengaturcaraan berstruktur
 
Fundamentals of Programming Chapter 3
Fundamentals of Programming Chapter 3Fundamentals of Programming Chapter 3
Fundamentals of Programming Chapter 3
 
Small Basic Calculator Apps lesson
Small Basic Calculator Apps lessonSmall Basic Calculator Apps lesson
Small Basic Calculator Apps lesson
 
Basic Slides on Algorithms and Flowcharts
Basic Slides on Algorithms and FlowchartsBasic Slides on Algorithms and Flowcharts
Basic Slides on Algorithms and Flowcharts
 
Criticalthinking
CriticalthinkingCriticalthinking
Criticalthinking
 
Csallner algorithms1
Csallner algorithms1Csallner algorithms1
Csallner algorithms1
 
Lecture 1.pptx
Lecture 1.pptxLecture 1.pptx
Lecture 1.pptx
 
Algorithm types performance steps working
Algorithm types performance steps workingAlgorithm types performance steps working
Algorithm types performance steps working
 

Último

9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024Janet Corral
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 

Último (20)

9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 

Visual Problem Solving (Lecture)

  • 1. VISUAL PROBLEM SOLVING Computer Science 20S with Mr. Wachs – Thursday, September 16, 2021
  • 3. Algorithm Flowcharts have applications in many areas other than computer solutions For example, in how-to-build-it instructions and recipes An algorithm is a step-by- step procedure for solving a problem
  • 4. Algorithm (cont’d) An algorithm for baking a chocolate cake is the chocolate cake recipe An algorithm for repairing your Mustang carburetor is the instructions in the shop manual A flowchart is a “picture” of the algorithm If it is done well, it is like a road map, and the path to the solution will be smooth
  • 5. Algorithm (cont’d) A computer program is a set of instructions that tells a computer to solve a problem in a step-by-step manner The program is written from a logic representation The model we employ when using the computer to find a solution is first the algorithm and then the “picture” A flowchart
  • 6. Algorithm (cont’d) From the flowchart we form a computer program, which we use to arrive at the solution We can check the solution either by hand or by running the program Here are two analogous stages to problem solving (with the computer and without)
  • 7. Algorithm (cont’d) Without Computer With Computer 1. What is the problem? Same 2. Make a model of the problem Develop an algorithm 3. Analyze the model Use a flowchart? 4. Find the solution Write a computer program 5. Check the solution Run the program
  • 8. Problem Solving… Continuing with our analysis of higher-level problem solving techniques, today we will examine the concept of Top Down Design Problem solving often involves breaking a problem down into smaller more manageable parts Then deal with each part individually
  • 9. Top Down Design This method is well suited to problem solving It allows us to start with general steps and elaborate on them until the problem is solved The process of making the steps more and more specific in top down design is called stepwise refinement
  • 10. Let’s Try it… (1.) The problem: Building a barn This is a big project, so we break the project down into smaller steps
  • 11. Top Down Design (cont’d) Let’s Build a Barn Build Foundation Build Walls Build Roof Now continue with the step wise refinement, breaking down each section again
  • 12. Top Down Design (cont’d) Build a Barn Build Foundation Build Walls Build Roof step wise refinement could continue even more, but you see the pattern Dig Concrete Framing Paneling Rafters Shingles
  • 13. Top Down Design (cont’d) Hierarchy charts do not indicate the flow of data But instead illustrate the tasks, or modules, for each part of the solution The only flow of data important is what should go into and come out of each module
  • 14. Another Example… An ATM machine… ATM Machine Get Inputs Give Outputs Perform all Calculations First level hierarchy chart
  • 15. The ATM example (cont’d) Second level hierarchy chart for input Get Inputs Get Password Get Transaction Amount Get Transaction Type
  • 16. The ATM example (cont’d) Second level hierarchy chart for output Get Outputs Print Error Message Dispense Cash Print Balance
  • 17. The ATM example (cont’d) Second and third level hierarchy chart for calculations Perform Calculations Handle Deposits Handle Withdrawals Add amount to balance Check balance Subtract amount from balance Give an error message
  • 18. The ATM example (cont’d) The complete hierarchy chart for the ATM Perform all calculations Handle Deposits Handle Withdrawals Add amount to balance Check balance Subtract amount from balance Give an error message Give outputs Print error message Print balance Dispense cash Give Inputs Get password Get transaction Get amount ATM
  • 19. Top Down Design (cont’d) The use of top down design, or hierarchy charts is truly a divide and conquer method of problem solving
  • 20. Logical Representations A logical representation is some sort of model that represents processes in the real world In some sense, mathematics is a model that represents the logic of natural systems We have already used top down design diagrams and other logic representations Now we’ll examine another method commonly used in computer problem solving, flowcharts
  • 22. Flowchart Symbols The common flowchart symbols Start/Stop – necessary for every flowchart Operation – do something Arrow – shows direction of flow
  • 23. Flowchart Symbols (cont’d) Decision – answer yes or no Information in – “read in” Information out – “output box” Connector – used for larger flowcharts
  • 24. Let’s Try it… (1.) The problem: How do you enter a locked room?
  • 25. Solution… First, list all necessary steps (algorithm) Do not take anything for granted Second, put the steps in the correct order 1. Walk to the room 2. Stop at the door 3. Take keys from pocket 4. Choose correct key 5. Put key in lock
  • 26. Solution… 6.Turn key 7.Open door 8.Take key out of lock 9.Walk in Now the corresponding flowchart
  • 27. Solution… START Take out keys Walk to room Stop at door Choose key Put in lock Turn key Open door Take key out Walk in STOP
  • 28. Another one… The problem… You are in a house with a telephone, a doorbell, and a alarm clock You hear one of them ringing, what is the solution
  • 29. Solution… START Listen to the bell ringing Is it the telephone? Answer the phone Is it the doorbell? See who is at the door Turn off the alarm STOP N Y Y N
  • 30. “Decision Symbol” With this symbol, there is always one arrow coming in, but two arrows (the decision) coming out ? No Yes
  • 31. The problem… Flowchart our ATM machine example from earlier
  • 32. Solution… Get password Is Password correct Get type and amount Deposit or withdraw Is Amount < balance Add amount to balance Subtract from balance Give error message or response N N N Y Y Y Start Stop
  • 33. Last one… The problem… Leonardo Fibonacci of Pisa wrote in 1202 about the number of rabbits that would be found at the end of a year if we started with a single pair of rabbits The pair produced one pair of offspring after the second month Then they stopped breeding Each new pair also produced two more pairs in the same way then stopped breeding
  • 34. Problem (cont’d) The answer to the first year is as follows Number of additional pairs 1 1 2 3 5 8 13 21 34 55 89 144 Month 1 2 3 4 5 6 7 8 9 10 11 12 The first 2 months are both 1 (since there is only one additional pair) Each month after, is the sum of the 2 months before it This is know as the Fibonacci sequence
  • 35. Problem (cont’d) Looking at it mathematically… F1 = 1 This translates as “first month (F1) equals one pair” F2 = 1 This translates as “second month (F2) equals one additional pair” F3 = F2 + F1 = 1 + 1 This translates as “third month (F3) equals second month plus first month” F4 = F3 + F2 = 2 + 1 = 3 Etc. There is a definite pattern, and thus we have found an algorithm to find all the terms
  • 36. Start Let the old Term equal 0 Let the newest Term equal 1 Find sum of Old and new term Is sum > 100? Let old term equal The newest term Let the newest Term equal the sum Write out The sum Stop Y N Solution… For numbers up to 100