測試版本平台正在積極開發中;可能有錯誤、缺少功能,以及資料遺失的風險。感謝你的支持!

Algorithms

邊玩邊學

回答這些題目賺取能量,接著就能釣魚、探索。不需要帳號。

給老師: 為 Algorithms(Computer Science、CIE)準備好可直接使用的課程投影片, 複習筆記——用於你的課程,或把這個主題當成互動班級活動,讓學生以即時遊戲的方式進行。

課程筆記

What is an Algorithm?

  • An algorithm is a precise set of rules or instructions to solve a specific problem or task.
  • Algorithms can be designed using structure diagrams, flowcharts, or pseudocode.
  • A well-designed algorithm should be interpretable by a new user to explain its purpose.

Structure Diagrams

  • Structure diagrams show hierarchical top-down design in a visual form.
  • Each problem is divided into sub-problems, and each sub-problem is further divided.
  • At each level, the problem is broken down into more detailed tasks that can be implemented using a single subroutine.
  • Example: A mobile app structure diagram might show top-level modules like 'Login', 'Main Menu', and 'Settings', each with sub-tasks.

Flowcharts

  • Flowcharts use shapes to represent different functions (e.g., process, decision, input/output).
  • Lines show the flow of control between steps.
  • Common shapes: oval (start/end), rectangle (process), diamond (decision), parallelogram (input/output).
  • Example: A flowchart for age verification inputs age, checks if ≥18, and outputs appropriate message.

Pseudocode

  • Pseudocode is a text-based tool using short English words/statements to describe an algorithm.
  • It is more structured than plain English but very flexible.
  • Use INPUT and OUTPUT statements (not `print()` or `input()` with brackets).
  • Example: `INPUT Age` / `IF Age ≥ 18 THEN OUTPUT "Welcome"`.
  • Default to pseudocode when writing algorithms; use flowcharts only when asked.

Explaining Algorithms

  • To explain an algorithm, follow the instructions step by step to determine its purpose.
  • Look for comments in the code, consider the context, and test with different inputs.
  • The algorithm's purpose should become clear by tracing its logic.
  • Example: A REPEAT loop that inputs 10 numbers and outputs the total adds ten user-entered numbers.

Worked Example: Grade Assignment

  • Input marks are stored in an array `Score[]`.
  • Each mark is checked against boundaries (70, 60, 50, 40, 30) to assign a grade (A–F).
  • The grade is stored in `Grade[]` at the same index as the mark.
  • The algorithm repeats until 30 marks have been input and processed.

投影片

Sign up free to view the lesson slides

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

練習題

免費預覽——52 題中的 8 題。註冊即可查看全部。
  1. 1.What is an algorithm?

    Easy
    • AA precise set of rules or instructions to solve a specific problem
    • BA type of computer hardware
    • CA programming language
    • DA data structure
  2. 2.Which of the following is NOT a method for designing an algorithm?

    Easy
    • AStructure diagrams
    • BFlowcharts
    • CPseudocode
    • DBinary search
  3. 3.In a flowchart, which shape is used to represent a decision?

    Easy
    • ARectangle
    • BDiamond
    • COval
    • DParallelogram
  4. 4.What does a structure diagram show?

    Easy
    • AThe flow of control through an algorithm
    • BHierarchical top-down design, breaking a problem into sub-problems
    • CThe exact syntax of a programming language
    • DThe data types used in a program
  5. 5.In pseudocode, which of the following is the correct way to output a message?

    Easy
    • AOUTPUT 'Hello'
    • Bprint('Hello')
    • CPRINT 'Hello'
    • DDISPLAY 'Hello'
  6. 6.Consider the following pseudocode: Count ← 1 Total ← 0 REPEAT INPUT Number Total ← Total + Number Count ← Count + 1 UNTIL Count > 10 OUTPUT Total What does this algorithm do?

    Medium
    • AIt outputs the sum of ten numbers entered by the user
    • BIt outputs the average of ten numbers entered by the user
    • CIt outputs the largest of ten numbers entered by the user
    • DIt outputs the count of numbers entered
  7. 7.In the following pseudocode, what is stored in Grade[2] if the input Score[2] is 65? Count ← 0 REPEAT INPUT Score[Count] IF Score[Count] ≥ 70 THEN Grade[Count] ← 'A' ELSE IF Score[Count] ≥ 60 THEN Grade[Count] ← 'B' ELSE IF Score[Count] ≥ 50 THEN Grade[Count] ← 'C' ELSE IF Score[Count] ≥ 40 THEN Grade[Count] ← 'D' ELSE IF Score[Count] ≥ 30 THEN Grade[Count] ← 'E' ELSE Grade[Count] ← 'F' ENDIF ENDIF ENDIF ENDIF ENDIF Count ← Count + 1 UNTIL Count = 30

    Medium
    • A'B'
    • B'A'
    • C'C'
    • D'D'
  8. 8.Which of the following is a characteristic of pseudocode?

    Easy
    • AIt uses strict syntax like a programming language
    • BIt is a visual tool using shapes
    • CIt uses short English words/statements to describe an algorithm
    • DIt is written in binary

Unlock all 52 questions & more

建立免費帳號,即可查看這個主題的所有題目、投影片、字卡與複習筆記。

歷屆試題

這個主題的歷屆試題練習即將推出。
即將推出