Computer Science - Algorithms and Flowcharts

Algorithms and Flowcharts

Introduction

  • Topic: Algorithms and Flowcharts

  • Date: September 13, 2024

  • Key Concepts: Instructions, sequences, programs, flowcharts, decision-making, error handling.

Objectives and Outcomes

  • Objectives:

    • Define instruction and sequence.

    • Identify key flowchart symbols.

    • Describe how flowchart symbols are used.

    • Apply understanding to use sequence to order instructions.

    • Explain common algorithms used in everyday technology such as search and sort functions.

  • Outcomes:

    • State the correct order for traversing a zebra crossing.

    • Organize instructions for making a cup of tea.

    • Develop a program to run a zebra crossing and crossing patrol.

    • Analyze a flowchart for potential errors and suggest improvements.

  • Keywords: Instructions, Algorithms, Sequences, Programs, Flowcharts, decision-making, error handling.

Programs

  • Understanding Programs:
    Computers require instructions to perform tasks effectively.

  • Algorithm: A detailed set of instructions for a computer to follow, essential in programming.

  • Sequence: Multiple instructions placed in a specific order to achieve a desired outcome.

  • Program: A comprehensive sequence of instructions that tells a computer what to do, step by step.

  • Analogy: Similar to a recipe where instructions are followed meticulously to create a meal, ensuring each step is completed in the correct order.

  • Step-by-step Instruction: This systematic approach of solving a problem is defined as an Algorithm.

Zebra Crossing - Correct Sequence

  • Task: Correctly order the instructions to help pedestrians use a zebra crossing safely.

  • Scenario: Zebra crossing on a wide road with an island in the middle.

  • Instructions and Correct Order:

    1. Stop at the side of the road looking to the other side of the Zebra crossing - 1

    2. Look right - 2

    3. Wait until traffic from the right has stopped or the road is clear - 3

    4. Step onto the first half of the zebra crossing - 4

    5. Walk to the island looking both ways and listening - 5

    6. Stop at the island - 6

    7. Look left - 7

    8. Stay on the island until traffic from the left has stopped or the road is clear - 8

    9. Step onto the second half of the zebra crossing - 9

    10. Walk to the other side of the road looking both ways and listening - 10

Flowcharts

  • Definition: A flowchart is a diagram that visually represents a sequence of steps and decisions to help solve a problem (Algorithm).

  • Components: A flowchart consists of symbols (such as circles, rectangles, diamonds) and arrows that connect them, highlighting the flow of actions.

  • Purpose: Utilized to design a logical sequence that can effectively control an event or process.

  • Actions can be ordered, reordered, or removed if they are deemed unnecessary in optimized workflow.

Flowchart Symbols

  • Key Symbols: Four main symbols used in flowcharts:

    • START / STOP: Indicates the beginning or end of a program.

    • INPUT or OUTPUT: Represents receiving data or providing output signals.

    • DECISION: Indicates a branching point where a question is asked with a YES or NO answer.

    • PROCESS/DELAY: Demonstrates an action that gives an instruction, often involving a delay.

    • START/STOPSTART / STOP

    • INPUT/OUTPUTINPUT / OUTPUT

    • DECISIONDECISION

    • PROCESS/DELAYPROCESS / DELAY

Making a Cup of Tea - Creating a Sequence

  • Task: Place flowchart instructions in order of how to make a cup of tea.

  • Considerations: Is there only one correct sequence? What decisions could be added to this flowchart? Different methods of making tea can be considered (e.g., using a teabag vs. loose leaf tea).

  • Instructions (in no particular order): Pour tea into cup, Add water, Boil water, Add sugar, Pour milk into cup, Drink tea, Stop, Start, Remove teabag from teapot, Put teabag in teapot.

Human vs. Computer

  • Discussion: Which is better, a human or a computer in problem-solving?

  • Considerations: Why do you think one is better? Explain your reasoning by considering tasks that may require creativity versus tasks that require precision and repetition.

Computer Control - Advantages

  • Advantages of using computers in controlling processes include:

    • Do not need breaks or rest.

    • Do not take sick days or holidays.

    • Can repeat actions in an identical way indefinitely without deviation.

    • Can operate in environments that are too dangerous for human workers.

    • Don’t require financial compensation.

    • Can process data without delay, responding in real-time.

    • Capable of managing hundreds or thousands of inputs simultaneously, greatly increasing efficiency.

Computer Control - Disadvantages

  • Disadvantages:

  • Computers are only as reliable as their programming, which may contain errors that can lead to incorrect outcomes.

  • They might not know how to respond when faced with unprogrammed conditions or novel situations.

  • Underpowered machines could fail to perform well in time-sensitive situations.

  • Dependence on power supply means a cut can render systems inoperative.

  • Investment in technology can be high, including purchase, maintenance, and necessary upgrades.

Flowchart Symbols - What do you remember?

  • Task: Identify the names of flowchart symbols.

  • Extension: Discuss the purpose of these symbols in flowcharting.

  • Symbols: START / STOP, DECISION, INPUT or OUTPUT, PROCESS or DELAY, and DIRECTION for the flow of action.