Notes

3.3

an Algorithm is a set of instruction that accomplish a task

Sequencing

  • The order of how you do something
  • Like the instructions of a teacher and howo you follow them

Selection

  • Allows the algorithm to make a decision based on if a condition is met
    • Go to the gas station if your tank is empty, dont if its full.

Iteration

  • A loop that does something over and over again until a condition is met

Mathematical Expressions

  • Sequential statements specify how signals are assigned and the process that is executed as a whole.
    • Execute in the order in which they appear

Examples of arithmetic operators:

-Addition: a+b -Subtraction: a-b -Multiplication: a*b -Division: a/b -Modulus: a MOD b (a and b can be string or number)

Modulus operator divides the given numeratior by the denominatior to find the result.

  • The syntax is %.

Strings

  • String concatenation joins two or more strings end to end to make a new string

Examples of strings in pseudocode:

  • len (str)
    • returns the number of character is str
    • len(“hello”) returns 5
  • concat (str1, str2)
    • returns a single string consisting of str1 followed by str 2
    • concat(“hello”,”world”) return ‘hello world’
  • substring (str1, str2, length)
    • returns a substring of consecutive character from str1, starting the character at position ‘start’ and containing ‘length’ character
    • substring (“hello”,”world”, 4,5) returns ‘lo wor’

Hacks

Hack #1

Sequencing

  • The order of how you do something
  • Like the instructions of a teacher and howo you follow them
  • It was 1-5 on the image

Selection

  • Allows the algorithm to make a decision based on if a condition is met
    • Go to the gas station if your tank is empty, dont if its full.
  • It was #3 on the image

Iteration

  • A loop that does something over and over again until a condition is met
  • Was #4 on the image

Hack #2

Crossword Puzzle

  • 1 down: Iteration
  • 2 down: Selection
  • 3 accross: Sequence

Find the solution

Hack #3

Quiz