Professional Documents
Culture Documents
SEQUENCE IS ONE OF THE THREE BASIC BUILDING BLOCKS OF ALGORITHM DESIGN. IT IS A PROGRAMMING CONSTRUCT.
WHAT IS IT?
An algorithm consists of a series of steps. Sequence
refers to the order in which those steps are arranged
and carried out.
HOW IS IT USED?
It is important that the steps in a computer algorithm
are carried out in the correct order. Carrying out
steps in the wrong order may produce unexpected results
or errors in the program.
EXAMPLES
The algorithms below show the importance of sequence when calculating 5+3x2.
16
when clicked
var answer = 5 + 3;
set answer to 5 + 3
answer = answer * 2;
set answer to answer * 2
console.log(answer);
START START
say answer // output: 16
STATEMENT STATEMENT
5+3=8 3x2=6 11
when clicked var answer = 3 * 2;
STATEMENT STATEMENT set answer to 3 * 2 answer = 5 + answer;
8 x 2 = 16 5 + 6 = 11 set answer to 5 + answer console.log(answer);
say answer // output: 11
STATEMENT STATEMENT
output 16 output 11 Adrian Park 2016. This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
FURTHER INVESTIGATION
END END
How does the use of functions or procedures affect
sequence in a program?
FLOW CONTROL
SELECTION
SELECTION IS ONE OF THE THREE BASIC BUILDING BLOCKS OF ALGORITHM DESIGN. IT IS A PROGRAMMING CONSTRUCT.
WHAT IS IT?
Algorithms often include decisions or choices about what
to do based on user input or the state of the program.
Decision making in progamming is known as selection.
HOW IS IT USED?
Selection is used when the algorithm needs to decide
whether to do something. It is also used to choose one
option from a number of options available. Selection
changes the path the program takes.
EXAMPLES
Each of the algorithms below outputs a message based on the users score.
FLOW DIAGRAM SCRATCH JAVASCRIPT
Adrian Park 2016. This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
ITERATION
ITERATION IS ONE OF THE THREE BASIC BUILDING BLOCKS OF ALGORITHM DESIGN. IT IS A PROGRAMMING CONSTRUCT.
WHAT IS IT?
Iteration is when a sequence of steps or operations are
repeated again and again until some condition is met.
It may also be referred to as repetition or a loop.
HOW IS IT USED?
Iteration is used when a sequence of steps should be
repeated a set number of times or until some condition
is met. Iteration is often used to step through lists
of items in arrays.
EXAMPLES
Each of the algorithms below outputs the numbers 1 through 10.
FLOW DIAGRAM SCRATCH JAVASCRIPT
i > 10? Adrian Park 2016. This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
FURTHER INVESTIGATION
YES There are different forms of iteration (e.g. counter
or condition controlled). Find out how they work.
END
Find out how to use iteration to step through arrays.
FLOW CONTROL
SEQUENCE IS ONE OF THE THREE BASIC BUILDING BLOCKS OF ALGORITHM DESIGN. IT IS A PROGRAMMING CONSTRUCT.
WHAT IS IT?
An algorithm consists of a series of steps. Sequence
refers to the order in which those steps are arranged
and carried out.
HOW IS IT USED?
It is important that the steps in a computer algorithm
are carried out in the correct order. Carrying out
steps in the wrong order may produce unexpected results
or errors in the program.
EXAMPLES
The algorithms below show the importance of sequence when calculating 5+3x2.
16
when clicked
answer = 5+3
set answer to 5 + 3
answer = answer*2
set answer to answer * 2
print(answer)
START START
say answer // output: 16
STATEMENT STATEMENT
5+3=8 3x2=6 11
when clicked answer = 3*2
STATEMENT STATEMENT set answer to 3 * 2 answer = 5+answer
8 x 2 = 16 5 + 6 = 11 set answer to 5 + answer print(answer)
say answer // output: 11
STATEMENT STATEMENT
output 16 output 11 Adrian Park 2016. This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
FURTHER INVESTIGATION
END END
How does the use of functions or procedures affect
sequence in a program?
FLOW CONTROL
SELECTION
SELECTION IS ONE OF THE THREE BASIC BUILDING BLOCKS OF ALGORITHM DESIGN. IT IS A PROGRAMMING CONSTRUCT.
WHAT IS IT?
Algorithms often include decisions or choices about what
to do based on user input or the state of the program.
Decision making in progamming is known as selection.
HOW IS IT USED?
Selection is used when the algorithm needs to decide
whether to do something. It is also used to choose one
option from a number of options available. Selection
changes the path the program takes.
EXAMPLES
Each of the algorithms below outputs a message based on the users score.
FLOW DIAGRAM SCRATCH PYTHON
Adrian Park 2016. This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
ITERATION
ITERATION IS ONE OF THE THREE BASIC BUILDING BLOCKS OF ALGORITHM DESIGN. IT IS A PROGRAMMING CONSTRUCT.
WHAT IS IT?
Iteration is when a sequence of steps or operations are
repeated again and again until some condition is met.
It may also be referred to as repetition or a loop.
HOW IS IT USED?
Iteration is used when a sequence of steps should be
repeated a set number of times or until some condition
is met. Iteration is often used to step through lists
of items in arrays.
EXAMPLES
Each of the algorithms below outputs the numbers 1 through 10.
FLOW DIAGRAM SCRATCH PYTHON
output i say i i = 1
change i by 1
while i <= 10:
STATEMENT
NO i+1 wait 1 secs print(i)
i += 1
CONDITION
i > 10? Adrian Park 2016. This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
FURTHER INVESTIGATION
YES There are different forms of iteration (e.g. counter
or condition controlled). Find out how they work.
END
Find out how to use iteration to step through arrays.