algorithms 10 ist – topic 6. what is an algorithm? a series of detailed instructions or steps that...
TRANSCRIPT
![Page 1: Algorithms 10 IST – Topic 6. What is an algorithm? a series of detailed instructions or steps that will solve a problem in a set amount of time](https://reader038.vdocuments.mx/reader038/viewer/2022110116/55174d4c550346b1338b48f2/html5/thumbnails/1.jpg)
Algorithms
10 IST – Topic 6
![Page 2: Algorithms 10 IST – Topic 6. What is an algorithm? a series of detailed instructions or steps that will solve a problem in a set amount of time](https://reader038.vdocuments.mx/reader038/viewer/2022110116/55174d4c550346b1338b48f2/html5/thumbnails/2.jpg)
What is an algorithm?
“a series of detailed instructions or steps that will solve a problem in a set amount of time”
![Page 3: Algorithms 10 IST – Topic 6. What is an algorithm? a series of detailed instructions or steps that will solve a problem in a set amount of time](https://reader038.vdocuments.mx/reader038/viewer/2022110116/55174d4c550346b1338b48f2/html5/thumbnails/3.jpg)
Common examples of algorithms
Appliance Instructions
a logical set of steps to operate an appliance
![Page 4: Algorithms 10 IST – Topic 6. What is an algorithm? a series of detailed instructions or steps that will solve a problem in a set amount of time](https://reader038.vdocuments.mx/reader038/viewer/2022110116/55174d4c550346b1338b48f2/html5/thumbnails/4.jpg)
Common examples of algorithms
Recipes
a logical set of steps to cook an item
![Page 5: Algorithms 10 IST – Topic 6. What is an algorithm? a series of detailed instructions or steps that will solve a problem in a set amount of time](https://reader038.vdocuments.mx/reader038/viewer/2022110116/55174d4c550346b1338b48f2/html5/thumbnails/5.jpg)
Common examples of algorithms
Directions
a logical set of steps to arrive at a location
![Page 6: Algorithms 10 IST – Topic 6. What is an algorithm? a series of detailed instructions or steps that will solve a problem in a set amount of time](https://reader038.vdocuments.mx/reader038/viewer/2022110116/55174d4c550346b1338b48f2/html5/thumbnails/6.jpg)
Common examples of algorithms
Repair Manual
a logical set of steps to repair an item
![Page 7: Algorithms 10 IST – Topic 6. What is an algorithm? a series of detailed instructions or steps that will solve a problem in a set amount of time](https://reader038.vdocuments.mx/reader038/viewer/2022110116/55174d4c550346b1338b48f2/html5/thumbnails/7.jpg)
Advantages of using algorithms
solve problems in a logical step-by-step process avoiding vague “blundering-in-the-darkness”
finite – always has an end methods are standardised language is standardised
problems are described in the same way terminology is uniform
![Page 8: Algorithms 10 IST – Topic 6. What is an algorithm? a series of detailed instructions or steps that will solve a problem in a set amount of time](https://reader038.vdocuments.mx/reader038/viewer/2022110116/55174d4c550346b1338b48f2/html5/thumbnails/8.jpg)
Representing algorithms
Pseudocodeprecise form of English that uses keywords and rules of structure
Flowchartsa pictorial method of describing algorithms using a set of symbols, connecting lines and arrows.
![Page 9: Algorithms 10 IST – Topic 6. What is an algorithm? a series of detailed instructions or steps that will solve a problem in a set amount of time](https://reader038.vdocuments.mx/reader038/viewer/2022110116/55174d4c550346b1338b48f2/html5/thumbnails/9.jpg)
Pseudocode
Keyword Meaning
BEGINEND
to start a programto finish a program
INITIALISATIONEND INITIALISATION
to set any values at the start of a programto end the values section
BEGIN SUBPROGRAMEND SUBPROGRAM
to start a subprogramto finish a subprogram
IF <condition> THEN ELSEENDIF
to allow selection or choicefor another choice (may not be needed)to end the choice
CASEWHERE <condition> OTHERWISEENDCASE
to allow for many choicesto end the choices
WHILE <condition>ENDWHILE
to begin a loop at the start of a sequence
REPEATUNTIL <condition>
to begin a loop at the end of a sequence
![Page 10: Algorithms 10 IST – Topic 6. What is an algorithm? a series of detailed instructions or steps that will solve a problem in a set amount of time](https://reader038.vdocuments.mx/reader038/viewer/2022110116/55174d4c550346b1338b48f2/html5/thumbnails/10.jpg)
Pseudocode Rules
Keywords are written in CAPITALS
Basic keywords come in pairs … for every BEGIN there is an END
Indenting is used to show structure
Names of subprograms are underlined
![Page 11: Algorithms 10 IST – Topic 6. What is an algorithm? a series of detailed instructions or steps that will solve a problem in a set amount of time](https://reader038.vdocuments.mx/reader038/viewer/2022110116/55174d4c550346b1338b48f2/html5/thumbnails/11.jpg)
Flowcharts
![Page 12: Algorithms 10 IST – Topic 6. What is an algorithm? a series of detailed instructions or steps that will solve a problem in a set amount of time](https://reader038.vdocuments.mx/reader038/viewer/2022110116/55174d4c550346b1338b48f2/html5/thumbnails/12.jpg)
Flowchart Rules
There is only ever ONE WAY into a flowchart structure and ONE WAY out.
A single flowchart should fit on one page
If larger than one page … use subprograms
![Page 13: Algorithms 10 IST – Topic 6. What is an algorithm? a series of detailed instructions or steps that will solve a problem in a set amount of time](https://reader038.vdocuments.mx/reader038/viewer/2022110116/55174d4c550346b1338b48f2/html5/thumbnails/13.jpg)
Control Structures
there are 3 basic control structures to show the order in which statements are carried out:
sequencing (or steps)
selection (or choice)
repetition (or loops)
![Page 14: Algorithms 10 IST – Topic 6. What is an algorithm? a series of detailed instructions or steps that will solve a problem in a set amount of time](https://reader038.vdocuments.mx/reader038/viewer/2022110116/55174d4c550346b1338b48f2/html5/thumbnails/14.jpg)
Sequencing
most common
each step is carried out in order of its position
each step is done only once.
![Page 15: Algorithms 10 IST – Topic 6. What is an algorithm? a series of detailed instructions or steps that will solve a problem in a set amount of time](https://reader038.vdocuments.mx/reader038/viewer/2022110116/55174d4c550346b1338b48f2/html5/thumbnails/15.jpg)
Selection
Binary selection allows the choice between 2 possible paths if one condition is met then one path is taken, otherwise the other
path is taken
![Page 16: Algorithms 10 IST – Topic 6. What is an algorithm? a series of detailed instructions or steps that will solve a problem in a set amount of time](https://reader038.vdocuments.mx/reader038/viewer/2022110116/55174d4c550346b1338b48f2/html5/thumbnails/16.jpg)
Selection
Case or Multi-way selection allows the choice between 3 or more possible paths if the condition is met (TRUE) then one path is taken, otherwise
one of the other paths is taken
![Page 17: Algorithms 10 IST – Topic 6. What is an algorithm? a series of detailed instructions or steps that will solve a problem in a set amount of time](https://reader038.vdocuments.mx/reader038/viewer/2022110116/55174d4c550346b1338b48f2/html5/thumbnails/17.jpg)
Repetition carries out a particular action any number of times until a
condition is met a loop is created to return the program to a point where the
repetition starts and continues until the condition is met the loop must have a terminating (ending) condition that is…
tested at some time during each repetition updated during each repetition
![Page 18: Algorithms 10 IST – Topic 6. What is an algorithm? a series of detailed instructions or steps that will solve a problem in a set amount of time](https://reader038.vdocuments.mx/reader038/viewer/2022110116/55174d4c550346b1338b48f2/html5/thumbnails/18.jpg)
Repetition
Pre-test Repetition (While Loop / Guarded Loop) the condition is tested at the start of the loop if the condition is false the first time the processes will NEVER be
carried out. Pre-test loops end when the condition is false. Uses WHILE … ENDWHILE
![Page 19: Algorithms 10 IST – Topic 6. What is an algorithm? a series of detailed instructions or steps that will solve a problem in a set amount of time](https://reader038.vdocuments.mx/reader038/viewer/2022110116/55174d4c550346b1338b48f2/html5/thumbnails/19.jpg)
Repetition
Post-test Repetition (Repeat-Until Loop / Unguarded Loop) the condition is tested at the end of the loop after the loop has
been run through Post-test loops end when the condition is true Uses REPEAT … UNTIL
![Page 20: Algorithms 10 IST – Topic 6. What is an algorithm? a series of detailed instructions or steps that will solve a problem in a set amount of time](https://reader038.vdocuments.mx/reader038/viewer/2022110116/55174d4c550346b1338b48f2/html5/thumbnails/20.jpg)
Repetition
For-Next Repetition The body of the loop is executed a set number of times. A counter variable is given a starting value which is incremented
each time the loop is executed until a given final value is reached