Introduction to Coding Algorithms

Introduction to Algorithms

  • Algorithm: A step-by-step set of instructions designed to solve a problem or perform a computation.

  • Objective: Enables a solution to be expressed independently of programming languages, transforming specific user input into expected output.

Flowcharts and Pseudocode

  • Flowchart: A visual representation of an algorithm using standardized symbols connected by directional arrows.

    • Start / End: Rounded rectangle or oval shape indicating program entry or exit.

    • Input / Output: Parallelogram shape for taking inputs or returning results.

    • Process: Rectangle shape for operations, calculations, or data assignments.

    • Decision: Diamond shape representing conditional questions that split execution paths into TRUE or FALSE.   

      Standard flowchart symbols for Start/End, Input/Output, Process, and Decision
  • Pseudocode: Short, structured, readable textual statements where each numbered step corresponds directly to a flowchart shape.

Variables and Constants

  • Variable: A data element whose value can change during program execution (e.g., Height, Length, Age). A variable holds one value at a time.

  • Constant: A fixed data item defined by the programmer whose value remains unchanged throughout program execution (e.g., Pi, number of letters in the alphabet).

Stages of an Algorithm

  • Start: Initial step marking the start of execution (START).

  • Input: Captures individual data inputs sequentially (e.g., Input xx, Input yy).

  • Processing: Executes individual operations sequentially (e.g., Sum→x+y\text{Sum} \rightarrow x + y, Product→x∗y\text{Product} \rightarrow x * y).

  • Output: Returns individual output values sequentially (e.g., Output Sum, Output Product).

  • End: Final step concluding program execution (END).

Order of Instructions

  • Sequence Sensitivity: The order of execution is critical when subsequent processes depend on prior outcomes.

  • Mathematical Operations: Must strictly follow standard mathematical precedence rules such as BODMAS.

Decision Making and Logic

  • Boolean Variable: A variable type limited to holding one of two possible values: True or False.

  • Flowchart Decision: Uses a diamond shape containing a conditional query (e.g., a>b?a > b?). Path branching follows TRUE or FALSE arrows.   

    Flowchart decision diamond evaluating if a is greater than b
  • Pseudocode IF…THEN…ELSE Structure:

    • IF condition

    • THEN action if True

    • ELSE action if False

    • END IF

  • Nested IF Statement: Used when evaluating three or more potential outcomes by embedding a secondary condition inside the ELSE block.   

    Nested decision flowchart evaluating if a is greater than b, b is greater than a, or both are equal