Presentation is loading. Please wait.

Presentation is loading. Please wait.

Algorithms and Flow Charts

Similar presentations


Presentation on theme: "Algorithms and Flow Charts"— Presentation transcript:

1 Algorithms and Flow Charts

2 Algorithms A procedure or formula for solving a problem.
Drawing a square in Netlogo

3 Representation of Algorithms
Desirable Features Language independent Unambiguous Easy to understand A standard---understood and known by many Solution Flow charts

4 Drawing a square As a flow chart:

5 Using variables More general?

6 Repetition

7 Repetition in Netlogo On the previous slide while ;; repeats forever
loop repeat ;; repeats forever pd loop [ fd 0.5 rt 1 ] ;; the turtle draws a circle pd repeat 36 [ fd 1 rt 10 ]

8 Decision

9 Decision if else statement if statement [ ifelse (xcor > 0)
[ set color blue ] [ set color red ] ] [ if (xcor > 0) [ set color blue ] ]

10 Procedures

11 Input and Output

12 Symbol Summary These seven symbols are used the most:

13 The Bug Game Implemented in Netlogo; here is the file
Objective: pick up all the food and return home in the fewest moves

14 The Bug Game Write the procedure go using the following instructions (each instruction is actually a procedure call): turn-right turn-left move-forward dist (dist must be specified) pickup-food see-food (sets variables) see-start (sets variables) at-food (sets variables) at-start (sets variables)


Download ppt "Algorithms and Flow Charts"

Similar presentations


Ads by Google