-
Notifications
You must be signed in to change notification settings - Fork 0
Description
- Algorithms
An Algorithm is a finite set of instructions used to accomplish a task.
First component : Sequencing
Sequencing ensures that tasks are completed in a specific order which instructions are provided in.
step 1 --> step 2 --> step 3
Step by step algorithmic process using sequencial code
storing with variables done in order , variables store single value
ex:
grade = 82
highScore = currentScore
Sequencing ensures that each part of code is executed one after another
ex:
grade1 = 10
grade2 = grade1
averageGrade = (grade1 + grade2) / 2
DISPLAY(averageGrade)
Second component : Selections
Provides choices between separate, specific outcomes which are executed depending on the conditions
ex:
check for rain
if rain, bring umbrella
if no rain, leave umbrella at home
Third component : Iterations
creates a loop of repetition as long as something stands true
stops after condition is met or doesn't apply any longer
Examples of algorithms
algorithms can be represented through flow charts or pseudocode
see issue 3.3.1 for more examples
Arithmetic operations
addition : a + b
subtraction: a - b
multiplication a * b
division a / b
modulus a MOD b
9 MOD 2 = 1
PEMDAS --> parenthesis still come first