1 of 35

Planning Algorithms

Expanding Computer Science Education to ALL Students

2 of 35

Chili Game

2

Expanding Computer Science Education to ALL Students

3 of 35

Chili Game

What’s an algorithm �for winning?

3

Expanding Computer Science Education to ALL Students

4 of 35

Chili Game

4

Expanding Computer Science Education to ALL Students

5 of 35

5

Expanding Computer Science Education to ALL Students

6 of 35

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

7 of 35

Building Blocks of Algorithms

7

Selectionallows us to include more than one path through an algorithm.

Expanding Computer Science Education to ALL Students

8 of 35

Building Blocks of Algorithms

8

Iterationis 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

9 of 35

Building Blocks of Algorithms

9

(Selection)

(Iteration)

Expanding Computer Science Education to ALL Students

10 of 35

10

Expanding Computer Science Education to ALL Students

11 of 35

How We Can Express Algorithms

11

Expanding Computer Science Education to ALL Students

12 of 35

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

13 of 35

How We Can Express Algorithms

13

Expanding Computer Science Education to ALL Students

14 of 35

Flowchart Example

14

Expanding Computer Science Education to ALL Students

15 of 35

Example Problem

Consider this simple algorithm for calculating how old a dog is in dog years. It contains three steps, all in sequence:

  • ask how old the dog is in human years
  • multiply human years by seven to find out how old the dog is in dog years
  • print the answer on the screen

15

Expanding Computer Science Education to ALL Students

16 of 35

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

17 of 35

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

18 of 35

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

19 of 35

Flowchart Solution

19

Expanding Computer Science Education to ALL Students

20 of 35

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

21 of 35

Planning Algorithms for Your App

21

Expanding Computer Science Education to ALL Students

22 of 35

22

Mr. T #24

Lawrence Tureaud

Swipe right if you remember!

DATA ENTRY

  • Insert
  • Update
  • Delete

USER INTERFACE

  • Display photo & name at random
  • Swipe right to reduce frequency

MANAGEMENT

  • Create account
  • Update (import / export) data

Expanding Computer Science Education to ALL Students

23 of 35

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 of 35

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

25 of 35

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

26 of 35

Review

26

Expanding Computer Science Education to ALL Students

27 of 35

27

Expanding Computer Science Education to ALL Students

28 of 35

28

Expanding Computer Science Education to ALL Students

29 of 35

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 of 35

30

Expanding Computer Science Education to ALL Students

31 of 35

Algo-Rhythms!

31

Expanding Computer Science Education to ALL Students

32 of 35

Dice Algorithms!

32

Expanding Computer Science Education to ALL Students

33 of 35

33

Explain the algorithm using plain language.

Expanding Computer Science Education to ALL Students

34 of 35

Play Game! �== Trace Algorithm

34

Expanding Computer Science Education to ALL Students

35 of 35

Create Your Own Dice Game!

Create an algorithm for another dice game and represent it using a flowchart or pseudocode. Here are some options:

  1. Find an existing dice game.
  2. Create an original dice game!
  3. Remix a given algorithm to create a new game.

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