A Adam Learning
Back to notes
9618-AS-10-02Chapter 10Section 10.2short-answer

10.2 Arrays 数组概念简答

Review the exact wording students need for this knowledge point, then open a filtered question list when ready to practise.

Find questions for 9618-AS-10-02

Scope

本页整理 array terminology、1D/2D structure selection、使用数组的好处及算法描述用词。Array pseudocode、linear search 与 bubble sort 代码留到专项。

Core terms

  • Array:a fixed collection of elements of the same data type under one identifier。
  • Element:one stored value in the array。
  • Index/subscript:the value used to identify/access an element。
  • Lower bound:smallest valid index。
  • Upper bound:largest valid index。
  • Dimension:number of indexes required to identify one element。

ThisArray[n] has one dimension;Grid[row, column] has two dimensions。

Choosing 1D or 2D

Use a 1D array for a single list/sequence, such as 30 marks or 12 month names。Use a 2D array for tabular/grid data with two coordinates, such as students by tests, seats by row/column or game-board positions。

每个 array 的 elements 必须是同一 type。若每个 entity 同时有 STRING、DATE、REAL 等不同 fields,应先定义 record,再使用 array of records。

Benefits of arrays

  • Multiple values use one identifier, reducing the number of separate variable names。
  • Elements can be accessed using an index
  • A loop can iterate through elements, simplifying repeated processing。
  • Searching, sorting and organising data are easier to implement。
  • Program design, testing and maintenance become easier when the number of items changes。

Three-mark pattern

An array stores many values under one identifier. An index allows individual values to be accessed, and a loop can iterate through all elements, simplifying processing.

Describing array processing

即使题目说 “Do not include pseudocode”,算法描述仍应按步骤写:

  • Initialise an index/counter and any accumulator or current best value。
  • Iterate from lower bound to upper bound。
  • Use the loop counter as the array index。
  • Compare/process the current element。
  • Update the result when the condition is met。
  • Output/return after the loop。

例如 largest search 应把 Max 初始化为 an existing array element,而不是任意 0,否则全负数数据可能产生错误结果。

Exam checklist

  • Index、lower bound、upper bound 是否用词准确?
  • 1D/2D 的选择是否联系数据形状?
  • 是否误用 array 存储 mixed types?
  • Benefit 是否具体写出 index 和 loop?
  • 算法描述是否有 initialisation、iteration、comparison、update、output?

完整 array declarations、search、sort 和 processing pseudocode 留到代码专项。

Practice This Knowledge Point

Open the question bank with this knowledge code already filled in. The filtered list will show matching questions for this note.

Open filtered practice
Source questions used