Planning Algorithms
Expanding Computer Science Education to ALL Students
Chili Game
2
Expanding Computer Science Education to ALL Students
Chili Game
What’s an algorithm �for winning?
3
Expanding Computer Science Education to ALL Students
Chili Game
4
Expanding Computer Science Education to ALL Students
5
Expanding Computer Science Education to ALL Students
Building Blocks of Algorithms
6
Sequencing �is the specific order in which instructions are performed in an algorithm.
Expanding Computer Science Education to ALL Students
Building Blocks of Algorithms
7
Selection �allows us to include more than one path through an algorithm.
Expanding Computer Science Education to ALL Students
Building Blocks of Algorithms
8
Iteration �is the process of repeating steps.
It allows algorithms to be simplified by stating that certain steps will repeat until told otherwise.
Expanding Computer Science Education to ALL Students
Building Blocks of Algorithms
9
(Selection)
(Iteration)
Expanding Computer Science Education to ALL Students
10
Expanding Computer Science Education to ALL Students
How We Can Express Algorithms
11
Expanding Computer Science Education to ALL Students
Pseudocode Example
REPEAT UNTIL answer = 'Computer Science'� OUTPUT 'What is the best subject you take?'� INPUT user inputs the best subject they take� STORE the user's input in the answer variable� IF answer = 'Computer Science' THEN� OUTPUT 'Of course it is!'� ELSE� OUTPUT 'Try again!'
12
Expanding Computer Science Education to ALL Students
How We Can Express Algorithms
13
Expanding Computer Science Education to ALL Students
Flowchart Example
14
Expanding Computer Science Education to ALL Students
Example Problem
Consider this simple algorithm for calculating how old a dog is in dog years. It contains three steps, all in sequence:
15
Expanding Computer Science Education to ALL Students
Potential Solutions
OUTPUT 'How old is your dog?'
INPUT user inputs their dog's age in human years
STORE the user's input in the human_years variable �dog_years = human_years * 7
OUTPUT 'In dog years, your dog is aged' + dog_years
16
Expanding Computer Science Education to ALL Students
Example Problem #2
Create an algorithm to compare your age to your dog’s age (in dog years).
17
Expanding Computer Science Education to ALL Students
Pseudocode Solution
INPUT user inputs their dog's age in human years
STORE the user's input in the human_years variable�dog_years = human_years * 7
OUTPUT 'In dog years, your dog is aged ' + dog_years
OUTPUT 'How old are you?'
INPUT user inputs their age
STORE the user's input in the user_age variable
IF dog_years > user_age THEN� OUTPUT 'Your dog is older than you!'
ELSE� OUTPUT 'Your dog is not older than you.'
18
Expanding Computer Science Education to ALL Students
Flowchart Solution
19
Expanding Computer Science Education to ALL Students
Debug It!
OUTPUT 'How old are you?'
INPUT user inputs their age
STORE the user's input in the age variable
IF age > 17 THEN� OUTPUT 'You are old enough to drive a car!'
ELSE IF age < 17 THEN � OUTPUT 'You are too young to drive a car.'
20
Expanding Computer Science Education to ALL Students
Planning Algorithms for Your App
21
Expanding Computer Science Education to ALL Students
22
Mr. T #24
Lawrence Tureaud�
Swipe right if you remember!
DATA ENTRY
USER INTERFACE
MANAGEMENT
Expanding Computer Science Education to ALL Students
23
“Add student” �button press
INPUT ‘full name’
Does last name exist?
INPUT ‘nickname’
YES
INPUT photo
INPUT ‘Do you want to update student?’�(Yes / No)
Response = Yes
Update student
stop
YES
NO
NO
Expanding Computer Science Education to ALL Students
24
“Add student” �button press
INPUT ‘last name’
Does last name exist?
INPUT ‘first name’
YES
Does first name match existing first name?
INPUT photo
YES
INPUT ‘Do you want to update student?’�(Yes / No)
Response = Yes
NO
Update student
stop
YES
NO
NO
Expanding Computer Science Education to ALL Students
Your Mission
Plan the algorithm for �(a portion of) your app
using flowcharts or pseudocode. Then, begin your paper prototype and prepare to present.
25
Expanding Computer Science Education to ALL Students
Review
26
Expanding Computer Science Education to ALL Students
27
Expanding Computer Science Education to ALL Students
28
Expanding Computer Science Education to ALL Students
Representing Algorithms
OUTPUT 'How old is your dog?'
INPUT user inputs their dog's age in human years
STORE the user's input in the human_years variable �dog_years = human_years * 7
OUTPUT 'In dog years, your dog is aged' + dog_years
29
Expanding Computer Science Education to ALL Students
30
Expanding Computer Science Education to ALL Students
Algo-Rhythms!
31
Expanding Computer Science Education to ALL Students
Dice Algorithms!
32
Expanding Computer Science Education to ALL Students
33
Explain the algorithm using plain language.
Expanding Computer Science Education to ALL Students
Play Game! �== Trace Algorithm
34
Expanding Computer Science Education to ALL Students
Create Your Own Dice Game!
Create an algorithm for another dice game and represent it using a flowchart or pseudocode. Here are some options:
Then, swap with another group to help you test and refine.
Need a 🌶 challenge? Implement your algorithm!
35
Expanding Computer Science Education to ALL Students