Algorithms, flowcharts and pseudocode

边玩边学

回答这些题目来赚取能量,然后钓鱼探索。无需账号。

给教育者: 面向 Algorithms, flowcharts and pseudocode(KS3 Computing,Computer Science)的即用型课程幻灯片, 复习笔记——用在你的课堂上,或将该知识点作为学习者可实时游玩的互动课堂活动来运行。

课程笔记

What is an Algorithm?

  • An algorithm is a precise sequence of instructions that solves a problem or performs a computation.
  • It must be finite – it stops eventually after a finite number of steps.
  • Algorithms are used as specifications for calculations and data processing.
  • They can be expressed in flowcharts, pseudocode, or a programming language.
  • A heuristic is a problem-solving approach without a well-defined correct result (e.g., social media recommendations).

An algorithm is a finite, unambiguous sequence of steps that turns an input into an output.

An algorithm is a finite, unambiguous sequence of steps that turns an input into an output.

Expressing Algorithms: Flowcharts

  • A flowchart uses standard symbols to show the steps of an algorithm visually.
  • Oval (terminator) – start and end of the algorithm.
  • Rectangle (process) – a calculation or action (e.g., 'Add 1 to count').
  • Diamond (decision) – a yes/no question that branches the flow.
  • Parallelogram (input/output) – reading data or displaying results.
  • Arrows show the flow of control between steps.

The standard flowchart symbols - terminal, process, input/output and decision - and the same logic written as pseudocode.

The standard flowchart symbols - terminal, process, input/output and decision - and the same logic written as pseudocode.

Expressing Algorithms: Pseudocode

  • Pseudocode is a plain-language description of an algorithm, not tied to a specific programming language.
  • It uses keywords like IF, THEN, ELSE, WHILE, FOR, INPUT, OUTPUT.
  • It is more precise than natural language but easier to read than code.
  • Example: `IF score ≥ 50 THEN OUTPUT "Pass" ELSE OUTPUT "Fail"`.
  • Pseudocode helps plan and communicate algorithms before coding.

Pseudocode keywords for input, output, assignment and selection, with the same logic drawn as a flowchart.

Pseudocode keywords for input, output, assignment and selection, with the same logic drawn as a flowchart.

Tracing an Algorithm

  • Tracing means manually following the steps of an algorithm with sample inputs to check it works.
  • Use a trace table with columns for variables, conditions, and output.
  • Record the value of each variable after every step.
  • Tracing helps find logic errors and verify correctness.
  • Example: trace a loop that sums numbers from 1 to 5 – track `sum` and `i`.

A trace table records one row per step: the input taken, the variable values, the decision made and any output.

A trace table records one row per step: the input taken, the variable values, the decision made and any output.

Precision and Avoiding Ambiguity

  • Algorithms must be unambiguous – each step has exactly one meaning.
  • Vague instructions like 'add a few' are not algorithmic.
  • Use clear, specific language: 'Add 1 to count' not 'increase count'.
  • Flowcharts and pseudocode reduce ambiguity by using structured symbols and keywords.
  • A well-defined algorithm has a clear start, finite steps, and defined output.

Steps in the wrong order give the wrong result even when every step is correct.

Steps in the wrong order give the wrong result even when every step is correct.

History of Algorithms

  • Algorithms date back to ancient civilizations: Babylonian (c. 2500 BC), Egyptian (c. 1550 BC), Indian, Greek, Chinese, and Arabic.
  • The Euclidean algorithm (c. 300 BC) finds the greatest common divisor.
  • The Sieve of Eratosthenes (c. 240 BC) finds prime numbers.
  • Al-Khwarizmi (9th century) formalized algorithms as systematic, finite steps; the word 'algorithm' comes from his name.
  • Al-Kindi developed the first cryptographic algorithm using frequency analysis.

Key Takeaways

  • An algorithm is a step-by-step recipe for a computer or human to follow.
  • Flowcharts and pseudocode are two ways to represent algorithms.
  • Always trace your algorithm to ensure it works for all inputs.
  • Precision is key – avoid ambiguity.
  • Algorithms are fundamental to computer science and problem-solving.

One algorithm written three ways: structured English, pseudocode and a flowchart.

One algorithm written three ways: structured English, pseudocode and a flowchart.

幻灯片

Sign up free to view the lesson slides

Step through every slide for this topic — plus flashcards and revision notes — with a free account.

练习题

免费预览——57 题中的 8 题。注册即可查看全部。
  1. 1.What is an algorithm?

    Easy
    • AA precise sequence of instructions to solve a problem
    • BA random set of steps that may or may not work
    • CA type of computer hardware
    • DA programming language
  2. 2.An algorithm must always terminate (stop eventually).

    Easy

    True or false?

  3. 3.Which of the following is NOT a standard flowchart symbol?

    Easy
    • AOval
    • BRectangle
    • CDiamond
    • DTriangle
  4. 4.In a flowchart, what does a diamond shape represent?

    Easy
    • AA process
    • BA decision
    • CInput/output
    • DStart or end
  5. 5.Match each flowchart symbol to its meaning.

    Easy
    • Oval
    • Rectangle
    • Diamond
    • Parallelogram
    • Start/End
    • Process
    • Decision
    • Input/Output
  6. 6.Pseudocode is written in a specific programming language such as Python.

    Easy

    True or false?

  7. 7.Which of the following is an example of an algorithm?

    Medium
    • AA recipe for baking a cake
    • BA random guess at a number
    • CA list of your favourite songs
    • DA painting of a landscape
  8. 8.Arrange the following steps to make a simple algorithm for making a cup of tea:

    Medium
    • Boil water
    • Add tea bag to cup
    • Pour water into cup
    • Remove tea bag

Unlock all 57 questions, flashcards & more

创建免费账号,即可查看该知识点的每一道题、幻灯片、闪卡和复习笔记。

历年真题

该知识点的历年真题练习即将推出。
即将推出