Zum Inhalt springen

English:Algorithms and Flowcharts

Aus MOOCsWiki Staging
Die Druckversion wird nicht mehr unterstützt und kann Darstellungsfehler aufweisen. Bitte aktualisiere deine Browser-Lesezeichen und verwende stattdessen die Standard-Druckfunktion des Browsers.

Algorithms and Flowcharts



Introduction

An algorithm is a clear, ordered set of instructions for solving a problem or completing a task. Algorithms are not limited to computers. You use step-by-step procedures when you follow a recipe, find a route, sort cards, or decide what to pack for school. In computer science, algorithms describe what a computer or person should do and in what order.

A flowchart is a visual way to show the steps and decisions in an algorithm. It uses shapes connected by arrows so that you can follow the path from start to finish. Learning to write algorithms and read flowcharts helps you practice computational thinking, plan programs before coding, explain your ideas, and find mistakes more easily.

The Wikimedia Commons diagram above shows how a program flow can be represented visually. Notice that arrows connect different kinds of shapes to show what happens next.

The Crash Course video introduces algorithms in computer science. As you watch, look for the idea that a problem can often be solved in more than one way.


Learning Goals

By the end of this aiMOOC, you should be able to explain what an algorithm is, distinguish an algorithm from a flowchart, use common flowchart symbols, recognize sequence, selection, and iteration, write simple pseudocode, trace an algorithm with test data, find logical errors, and design a flowchart for a familiar problem.


What Makes an Algorithm Useful?

A useful algorithm gives enough information for someone else to follow it correctly. For Grades 7–8, you can check an algorithm with four questions:

  1. Clear instructions: Is every step understandable and unambiguous?
  2. Correct order: Are the steps arranged so that each one can be carried out at the right time?
  3. Finite process: Will the procedure eventually stop?
  4. Testable result: Can you try the algorithm with examples and check whether the result is correct?

For example, the instruction “make a sandwich” is too vague to be a complete algorithm. A clearer version names the actions in order: place bread on a plate, add the filling, add the second slice, and cut the sandwich. In a computer program, details matter even more because a computer follows the instructions it is given.

Algorithms can have inputs and outputs. An input is information supplied to a process, such as a number typed by a user. An output is the result produced, such as a message or calculated value. Some algorithms also store values in variables while they work.


Everyday Algorithms

You can find algorithmic thinking in many everyday situations. A school morning routine is mainly a sequence. Choosing whether to take an umbrella introduces a decision. Practicing ten spelling words repeats similar actions, so it introduces iteration.

A useful way to improve an everyday algorithm is to ask what could go wrong. If your “get ready for school” algorithm says “leave home” before “pack your bag,” the order needs to be corrected. If it says “keep checking your bag forever,” it does not finish and needs a stopping condition.


From Problem to Algorithm

Before drawing shapes, first understand the problem. A simple planning method is:

  1. Define the problem: State what you are trying to achieve.
  2. Identify inputs and outputs: Decide what information comes in and what result should come out.
  3. Break down the task: Divide the problem into smaller steps.
  4. Choose decisions and repetitions: Mark where the path can split or where steps may repeat.
  5. Test the plan: Try normal, unusual, and boundary examples.

This process is related to decomposition, one of the main ideas in computational thinking. A complex task becomes easier to reason about when you divide it into smaller parts.


Three Ways to Represent an Algorithm

An algorithm can be represented in different forms.

Natural language uses ordinary sentences. It is easy to begin with, but it can become vague if instructions are not precise.

Pseudocode uses structured, code-like language without requiring the exact rules of a programming language. For example:

INPUT number
IF number >= 0 THEN
    OUTPUT "Non-negative"
ELSE
    OUTPUT "Negative"
END IF

Flowcharts show the same logic visually. Shapes represent actions, input or output, and decisions, while arrows show the direction of control.

You should be able to move between these forms. If you can explain the same solution as steps, pseudocode, and a flowchart, you are showing that you understand the logic rather than only memorizing a diagram.


Flowchart Symbols

Flowcharts use commonly recognized shapes. The exact style can vary slightly between tools, but the following symbols are widely used in introductory computer science.


Start and End: Terminal Symbol

A rounded terminal shape marks where a flowchart begins or ends. A simple flowchart normally has a clear start and a clear stopping point.


Action: Process Symbol

A rectangle represents a process or action, such as “add 1 to score,” “calculate total,” or “set attempts to zero.”


Input or Output: Parallelogram

A parallelogram is commonly used for input or output. “Enter your name” is an input. “Display the total” is an output.


Choice: Decision Symbol

A diamond represents a question or condition that can lead to different paths. The outgoing arrows are usually labelled with results such as Yes and No or True and False.

A decision should be written so that its possible outcomes are clear. For example, “Is the password correct?” has two obvious paths. The flowchart can send the user to “Open account” when the answer is Yes and “Try again” when the answer is No.


Direction: Flowlines and Arrows

Arrows show the order in which steps happen. Read the flowchart by starting at the terminal and following each arrow. At a decision, follow the arrow that matches the answer to the question. When arrows cross or a chart becomes crowded, connectors can sometimes be used to make the diagram easier to read.


The Three Core Control Structures

Many beginner algorithms can be explained with three control structures: sequence, selection, and iteration. These structures are important because they also appear in most programming languages.


Sequence

A sequence is a set of steps carried out one after another in a fixed order.

Example: calculate the area of a rectangle.

INPUT length
INPUT width
area = length * width
OUTPUT area

There is no choice and no repetition in this simple version. The instructions are followed from top to bottom.


Selection

Selection means choosing between paths based on a condition. It is often written with IF and ELSE in pseudocode.

Example: decide whether a student has reached a target score.

INPUT score
IF score >= 50 THEN
    OUTPUT "Target reached"
ELSE
    OUTPUT "Keep practising"
END IF

The diagram shows the basic idea of an if-then-else decision. Only one branch is followed for each check of the condition.

This everyday-style flowchart illustrates how repeated questions and decisions can guide a process. When you read such a chart, focus on the conditions at each branch and where each arrow leads.


Iteration

Iteration means repeating a set of steps. Another common word for iteration is a loop. A loop needs a rule that determines when repetition continues or stops.

Example: count from 1 to 5.

count = 1
WHILE count <= 5
    OUTPUT count
    count = count + 1
END WHILE

A loop is useful when the same kind of action would otherwise have to be written many times. However, you must make sure that the loop can eventually end. If the condition never becomes false, an infinite loop can occur.

This flowchart lesson reviews common shapes and examples. Compare the diagrams in the video with the symbols above and notice how sequence, decisions, and subprocesses are connected.


Tracing an Algorithm

Tracing means following an algorithm step by step while keeping track of values and decisions. It is one of the best ways to test whether your logic works before writing a full program.

Suppose an algorithm reads a temperature and outputs “Cold” when the value is below 10, otherwise “Mild or warm.” If the input is 7, you trace the decision “Is 7 below 10?” The answer is Yes, so you follow the branch to “Cold.” If the input is 10, the condition is false because 10 is not below 10.

A trace table can help when values change during a loop. You create columns for important variables, then record their values after each step or iteration. This makes it easier to spot wrong updates or unexpected conditions.


Test Data

Do not test only one easy example. Good testing uses several kinds of data:

  1. Normal data: A typical value that should work.
  2. Boundary value: A value exactly at or close to an important limit.
  3. Invalid data: A value that should be rejected or handled safely when the algorithm includes validation.

For the condition “score is at least 50,” useful tests include 70 as a normal passing value, 50 as the boundary, 49 as just below the boundary, and a non-numeric input if the program is supposed to accept only numbers.


Debugging and Improving Flowcharts

A logical error occurs when an algorithm runs or can be followed but produces the wrong result. A flowchart can help you find such errors because the path is visible.

Common problems include steps in the wrong order, missing arrows, a decision with an unclear condition, branches that never rejoin when they should, a loop that never stops, or a result that is produced before all needed information is available.

To debug a flowchart, trace it with sample inputs. Say the current value of each variable, follow exactly one arrow at every decision, and compare the final output with what you expected. If the result is wrong, find the first point where the actual path differs from the intended path.


A More Complex Example

This Wikimedia Commons image shows a flowchart for calculating a factorial. You do not need to master factorial mathematics here. Instead, use the diagram as a reading challenge: identify the start and end, locate the repeated part, find the decision that controls the repetition, and follow the arrows to see how the process eventually stops.

This GCSE-level video connects flowcharts with pseudocode. Some details are beyond the minimum for Grades 7–8, but the comparison is useful because it shows how the same algorithmic idea can be expressed visually or in structured text.


Comparing Algorithms

Two algorithms can solve the same problem but use different numbers of steps. At this level, you can begin comparing algorithms by asking simple questions: Does the algorithm always give the correct result? Does it finish? Is it easy to understand? How many steps might it need for a small input and for a larger input?

For example, imagine searching a sorted list of names. A linear search checks items one by one. A binary search repeatedly checks the middle part of a sorted list and rules out half of the remaining items. The second method can use fewer comparisons on a large sorted list, but it depends on the data being ordered.

The goal is not always to find the shortest-looking flowchart. A good algorithm should first be correct and clear. Once that is true, you can think about efficiency.


Algorithms in the Real World

Algorithms help control games, maps, search engines, robots, recommendation systems, traffic signals, and many other digital systems. Some are simple; others use huge amounts of data and many interacting rules.

When algorithms affect people, designers also need to think about the quality of the data, possible mistakes, fairness, privacy, and whether users can understand important decisions. At Grades 7–8, the key idea is that an algorithm is created by people. Its results depend on the instructions and information it receives, so testing and responsible design matter.


Interactive Tasks


Quiz: Test Your Knowledge

What is an algorithm? (A clear ordered set of instructions) (!A type of computer screen) (!A random collection of pictures) (!A file that cannot be changed)




Which flowchart shape is commonly used for a decision? (A diamond) (!A rectangle) (!A circle) (!A straight line)




What do arrows show in a flowchart? (The direction in which steps are followed) (!The colour of each variable) (!The size of the computer) (!The difficulty of the task)




Which control structure carries out steps one after another? (Sequence) (!Selection) (!Iteration) (!Validation)




Which control structure chooses between different paths? (Selection) (!Sequence) (!Storage) (!Formatting)




What does iteration mean in an algorithm? (Repeating a set of steps) (!Deleting every decision) (!Drawing only rectangles) (!Running steps in a random order)




Why is a stopping condition important in a loop? (It prevents the repetition from continuing forever) (!It makes every input identical) (!It removes all outputs) (!It changes a decision into a process)




What is pseudocode used for? (Describing program logic in a structured readable form) (!Measuring the physical size of a computer) (!Replacing every algorithm with a picture) (!Connecting a monitor to a keyboard)




What does tracing an algorithm mean? (Following its steps with example data) (!Guessing the answer without reading the steps) (!Changing every input into text) (!Removing all arrows from a flowchart)




Which test value is especially useful near an important limit? (A boundary value) (!A decorative value) (!A hidden colour) (!A random label)





Memory Game

Algorithm A finite ordered set of instructions for solving a problem
Sequence Steps carried out one after another
Selection A choice between paths based on a condition
Iteration Repetition of a set of steps
Flowchart A visual diagram of steps and decisions
Pseudocode Structured readable text for describing program logic
Trace Following an algorithm step by step with sample data
Debugging Finding and correcting errors in a solution





Drag and Drop

Match the correct terms. Topic
Rounded terminal Start or end
Rectangle Process or action
Parallelogram Input or output
Diamond Decision or condition
Arrow Direction of flow




...


Crossword Puzzle

Algorithm What do you call a clear ordered procedure for solving a problem?
Flowchart What diagram uses connected shapes to show an algorithm?
Sequence What control structure performs steps in order?
Selection What control structure chooses a path using a condition?
Iteration What word means repeating a set of steps?
Debugging What process finds and corrects errors in an algorithm?





LearningApps


Cloze Text

Complete the text.

An

is an ordered set of instructions for solving a problem. A

represents those steps visually with connected shapes. A rectangle usually represents a

. A diamond usually represents a

. Carrying out steps in order is called

. Choosing between paths is called

. Repeating steps is called

. Following a solution step by step with example data is called

.




Open-Ended Tasks


Easy

  1. Morning routine algorithm: Write a clear algorithm with at least eight steps for getting ready for school, then ask a partner to identify any vague instruction.
  2. Paper flowchart: Draw a flowchart for deciding whether to take a coat based on the weather and label every decision branch clearly.
  3. Symbol photo poster: Create a poster that pairs the four main flowchart shapes with examples from everyday actions, using your own drawings or photographs.
  4. Algorithm interview: Interview a family member or classmate about a routine task and turn the explanation into a short ordered algorithm.


Standard

  1. Guessing game flowchart: Design a flowchart for a number-guessing game that gives feedback such as too high, too low, or correct.
  2. Trace table experiment: Create a short loop, trace it by hand for at least five iterations, and compare your predicted outputs with a simple program or classroom simulation.
  3. Pseudocode conversion: Write pseudocode for a school-day decision process and then convert the same logic into a flowchart.
  4. Tutorial video: Record a two-minute instructional video in which you explain sequence, selection, and iteration using one original example for each.


Advanced

  1. Algorithm comparison project: Compare two methods for searching a list of classroom items, count the steps used for several list sizes, and explain which method performs better under which conditions.
  2. Flowchart debugging challenge: Create a flowchart with three deliberate logical errors, exchange it with a partner, and document how each error was discovered and repaired.
  3. Local process study: Observe or visit a suitable school or community process such as borrowing a library book, model it as a flowchart, and suggest one realistic improvement.
  4. Responsible algorithm design: Design a simple rule-based recommendation algorithm, test it with varied sample users, and explain where unfair or misleading results could occur.



Learning Assessment

  1. Algorithm explanation assessment: Explain how clarity, order, and a stopping point affect the reliability of an algorithm, using one original example.
  2. Flowchart interpretation assessment: Trace a teacher-provided flowchart with three different inputs and justify every branch you follow.
  3. Representation transfer assessment: Convert a short natural-language procedure into pseudocode and a flowchart, then explain which representation makes each part of the logic easiest to see.
  4. Boundary testing assessment: Choose boundary and normal test data for an algorithm with a threshold and explain what each test is intended to reveal.
  5. Debugging assessment: Diagnose a logical error in a loop or decision flowchart, repair it, and show with sample data that the corrected version works.
  6. Algorithm comparison assessment: Compare two correct solutions to the same problem using correctness, clarity, number of steps, and assumptions as criteria.




Evidence of Learning

Important evidence of learning includes both what you know and what you can create or apply.

  1. Knowledge evidence: You can accurately explain algorithms, flowcharts, inputs, outputs, sequence, selection, iteration, tracing, and debugging.
  2. Symbol evidence: You can use and interpret terminal, process, input or output, decision, and flowline symbols appropriately.
  3. Design evidence: You can produce a complete algorithm, pseudocode description, and flowchart for a familiar problem.
  4. Testing evidence: You can select useful test data, trace values, and explain whether the observed result matches the intended result.
  5. Debugging evidence: You can locate a logical error and justify a correction rather than changing steps by guesswork.
  6. Product evidence: Your portfolio contains readable diagrams, written algorithms, trace tables, or short explanations that another learner can follow.
  7. Transfer evidence: You can apply algorithmic thinking to a new classroom, everyday, or community process that you have not previously practised.




OERs on the Topic

The English Wikipedia articles below provide further reading about the two main ideas in this course.




Linked Learning Areas

Algorithms and flowcharts connect problem solving, mathematical logic, communication, and programming. The most important links for further learning are shown below.


aiMOOC Projects