A Adam Learning
Back to notes
9618-AS-10-01Chapter 10Section 10.1short-answer

10.1 Data Types and Records 数据类型与记录简答

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-01

Scope

本页只整理 data type、record、array of records 的选择与解释。Record definition、field access 等 pseudocode 留到代码专项。

Data types

Data typeSuitable data
INTEGERWhole numbers, counts and indexes
REALValues with a fractional part, measurements and averages
CHAROne character
STRINGA sequence of characters, names and descriptions
BOOLEANTRUE or FALSE states
DATECalendar dates

选择类型必须根据 data 的含义,而不是只看样例外观。Telephone number 即使全是 digits,也通常用 STRING,因为不参与 arithmetic,且可能保留 leading zero。

Mark-secure reasoning

  • Count/number of items -> INTEGER because it is a whole number used in arithmetic。
  • Price/average -> REAL because it may contain a fractional part。
  • IsNew/InStock -> BOOLEAN because it has two logical states。
  • Initial/name -> CHAR for one character, STRING for multiple characters。

Record structure

A record holds:

  • A set of related data items
  • Items may have different data types
  • They are grouped under one identifier/entity

Three-mark justification

A record is suitable because it stores all data about one customer, the fields can have different data types, and the related fields are held under one identifier.

Array of records

One record represents one entity instance;an array of records stores many instances of the same record structure。

Benefits:

  • Mixed data types for each entity remain grouped under one identifier。
  • A loop can iterate through all records。
  • An array index can directly access a particular record。
  • Searching, sorting and processing become easier。
  • Code duplication is reduced, improving readability, testing and maintenance。

Choosing a structure

Names and marks for many students can use:

  • An array of records:each element contains one student's STRING name and INTEGER mark。
  • Or two parallel 1D arrays:one STRING array and one INTEGER array, where the same index links corresponding values

Record is usually safer because associated fields remain together and cannot easily get out of step。

Exam checklist

  • 是否说明 type 与数据含义匹配?
  • Record 是否写到 related data、different types、one identifier?
  • Many entities 是否使用 array of records?
  • Benefit 是否写出 loop/index/maintenance 的实际作用?

本页不包含 record pseudocode;定义、读写 fields 和 array-of-record processing 留到代码专项。

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