1 / 14

Algorithms and Flow Charts

Algorithms and Flow Charts. Algorithms. A procedure or formula for solving a problem. Drawing a square in Netlogo. Representation of Algorithms. Desirable Features Language independent Unambiguous Easy to understand A standard---understood and known by many Solution Flow charts.

raina
Télécharger la présentation

Algorithms and Flow Charts

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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 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 statement if else 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)

More Related