17
Algorithms Procedures, Flow Charts, Pseudo-Code 1

Algorithms - Roosevelt CS & Web Design · Pseudo-code for planning 14 Main design tool for planning software Capture the logic and flow of the algorithm Design is independent of implementation

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Algorithms - Roosevelt CS & Web Design · Pseudo-code for planning 14 Main design tool for planning software Capture the logic and flow of the algorithm Design is independent of implementation

AlgorithmsProcedures, Flow Charts, Pseudo-Code

1

Page 2: Algorithms - Roosevelt CS & Web Design · Pseudo-code for planning 14 Main design tool for planning software Capture the logic and flow of the algorithm Design is independent of implementation

Algorithms

2

What is an algorithm ?Why do we need them ?How do we describe one ?Specify vs. implement !

Page 3: Algorithms - Roosevelt CS & Web Design · Pseudo-code for planning 14 Main design tool for planning software Capture the logic and flow of the algorithm Design is independent of implementation

Algorithm

3

-- Oxford English Dictionary

from the Arabic al-Ḵuwārizmī, the native of Ḵwārazm, surname of the Arab mathematician Abu Ja'far Mohammed Ben Musa, who flourished early in the 9th cent., and through the translation of whose work on Algebra, the Arabic numerals became generally known in Europe.

Page 4: Algorithms - Roosevelt CS & Web Design · Pseudo-code for planning 14 Main design tool for planning software Capture the logic and flow of the algorithm Design is independent of implementation

What is an algorithm?

A procedure for doing somethingA list of steps to accomplish a taskA structured method for solving a problem

4

Page 5: Algorithms - Roosevelt CS & Web Design · Pseudo-code for planning 14 Main design tool for planning software Capture the logic and flow of the algorithm Design is independent of implementation

Algorithm examples

Recipes for cookingInstructions to assemble a productDescription of a sports playStrategy for searching the internetScheme for solving a problem

5

Page 6: Algorithms - Roosevelt CS & Web Design · Pseudo-code for planning 14 Main design tool for planning software Capture the logic and flow of the algorithm Design is independent of implementation

Step-by-step

1. Do this2. Do that3. Do another thing4. Do something else

6

Page 7: Algorithms - Roosevelt CS & Web Design · Pseudo-code for planning 14 Main design tool for planning software Capture the logic and flow of the algorithm Design is independent of implementation

Complexity

Simple algorithms are generally linearBut what happens when there are alternative choices ?Or unanticipated possibilities ?Things can get more complex...

7

Page 8: Algorithms - Roosevelt CS & Web Design · Pseudo-code for planning 14 Main design tool for planning software Capture the logic and flow of the algorithm Design is independent of implementation

8

Page 9: Algorithms - Roosevelt CS & Web Design · Pseudo-code for planning 14 Main design tool for planning software Capture the logic and flow of the algorithm Design is independent of implementation

Specify vs. implement

Specify: plan and designImplement: execute or run

9

Page 10: Algorithms - Roosevelt CS & Web Design · Pseudo-code for planning 14 Main design tool for planning software Capture the logic and flow of the algorithm Design is independent of implementation

Specifying an algorithm

Natural language (narrative text)Flow chart (visual schematic)Pseudo-code (shorthand text)But not programming languages

10

Page 11: Algorithms - Roosevelt CS & Web Design · Pseudo-code for planning 14 Main design tool for planning software Capture the logic and flow of the algorithm Design is independent of implementation

Natural language recipe

11

-- The Cape Cod Fish & Seafood Cookbook

Page 12: Algorithms - Roosevelt CS & Web Design · Pseudo-code for planning 14 Main design tool for planning software Capture the logic and flow of the algorithm Design is independent of implementation

Flow chart procedure

12

-- http://en.wikipedia.org/wiki/File:LampFlowchart.svg

How many engineers does it take to fix a broken lamp ?

Page 13: Algorithms - Roosevelt CS & Web Design · Pseudo-code for planning 14 Main design tool for planning software Capture the logic and flow of the algorithm Design is independent of implementation

Pseudo-code

13

Start the cat at the center of the stage

When the green flag is clicked:

Repeat 10 times:

Move the cat right 10 steps

Change its costume

Rotate it 10 degrees clockwise

Stop everything

Page 14: Algorithms - Roosevelt CS & Web Design · Pseudo-code for planning 14 Main design tool for planning software Capture the logic and flow of the algorithm Design is independent of implementation

Pseudo-code for planning

14

Main design tool for planning softwareCapture the logic and flow of the algorithmDesign is independent of implementationCan be translated into many languagesPolyglottous programmers !!!

Page 15: Algorithms - Roosevelt CS & Web Design · Pseudo-code for planning 14 Main design tool for planning software Capture the logic and flow of the algorithm Design is independent of implementation

Implementing an algorithm

World (cook the salmon)

Software (run the code)

15

Page 16: Algorithms - Roosevelt CS & Web Design · Pseudo-code for planning 14 Main design tool for planning software Capture the logic and flow of the algorithm Design is independent of implementation

Algorithms are

Everywhere

16

Page 17: Algorithms - Roosevelt CS & Web Design · Pseudo-code for planning 14 Main design tool for planning software Capture the logic and flow of the algorithm Design is independent of implementation

17