Skip to content

3.3 Lesson notes #1

@maya-dn

Description

@maya-dn
  1. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions