The Algorithm

10
CS 1 with Robots The Algorithm Institute for Personal Robots in Education (IPRE)

description

The Algorithm. Institute for Personal Robots in Education (IPRE) ‏. The Algorithm. “Algorithm: n. A finite set of unambiguous instructions performed in a prescribed sequence to achieve a goal” - The American Heritage Science Dictionary. The Algorithm. - PowerPoint PPT Presentation

Transcript of The Algorithm

Page 1: The Algorithm

CS 1 with Robots

The Algorithm

Institute for Personal Robots in Education

(IPRE)

Page 2: The Algorithm

Aug 20 2007 2

The Algorithm

“Algorithm:

n. A finite set of unambiguous instructions performed in a prescribed sequence to achieve a goal” - The American Heritage Science Dictionary

Page 3: The Algorithm

Aug 20 2007 3

The Algorithm

Al-Khwarizmi was a Persian mathematician who wrote a book on calculating with Hindu numerals in the 9th century A.D. When translated to Latin, a pluralized form of his name (algorismus) became synonymous with a system of calculation.

Page 4: The Algorithm

Aug 20 2007 4

Pizza Dough Recipe (Algorithm)

1. Gather Ingredients2. Combine sugar (1tbs), salt

(1tbs), olive oil (1tbs), flour (1c) in mixing bowl

3. Turn on mixer4. Add 1/4 cup of flour5. If dough comes off the sides go

to step 6, otherwise go back to step 4

6. Knead 15 minutes7. Let rest for at least 45 minutes in

warm area

1 dough ball

Page 5: The Algorithm

Aug 20 2007 5

N-Pizza Dough Algorithm

Gather IngredientsCombine sugar (N tbs), salt (N tbs), olive oil (N tbs), flour (N c) in mixing bowlTurn on mixerAdd N/4 cup of flourIf dough comes off the sides go to step 6, otherwise go back to step 4Knead 15 minutesLet rest for at least 45 minutes in warm area

N dough balls

Page 6: The Algorithm

Aug 20 2007 6

N-Pizza Dough Algorithm

Gather IngredientsCombine sugar (N tbs), salt (N tbs), olive oil (N tbs), flour (N c) in mixing bowlTurn on mixerAdd N/4 cup of flourIf dough comes off the sides go to step 6, otherwise go back to step 4Knead 15 minutesLet rest for at least 45 minutes in warm area

Sequence of Statements

N dough balls

Page 7: The Algorithm

Aug 20 2007 7

N-Pizza Dough Algorithm

Gather IngredientsCombine sugar (N tbs), salt (N tbs), olive oil (N tbs), flour (N c) in mixing bowlTurn on mixerAdd N/4 cup of flourIf dough comes off the sides go to step 6, otherwise go back to step 4Knead 15 minutesLet rest for at least 45 minutes in warm area

N dough balls

Variable

Page 8: The Algorithm

Aug 20 2007 8

N-Pizza Dough - Algorithm

Gather IngredientsCombine sugar (N tbs), salt (N tbs), olive oil (N tbs), flour (N c) in mixing bowlTurn on mixerAdd N/4 cup of flourIf dough comes off the sides go to step 6, otherwise go back to step 4Knead 15 minutesLet rest for at least 45 minutes in warm area

Conditional

Page 9: The Algorithm

Aug 20 2007 9

N-Pizza Dough - Algorithm

Gather IngredientsCombine sugar (N tbs), salt (N tbs), olive oil (N tbs), flour (N c) in mixing bowlTurn on mixerAdd N/4 cup of flourIf dough comes off the sides go to step 6, otherwise go back to step 4Knead 15 minutesLet rest for at least 45 minutes in warm area

SubroutinesMini-algorithms

N dough balls

Page 10: The Algorithm

Aug 20 2007 10

Programs - Algorithms at Work

Programs are the way we communicate with a computerSpecify the algorithmThis class uses the Python programming language Rather than pizza dough, we will use a robot as our favorite example