Use suitable identifier names for the representation of data used by a problem and represent these using an identifier table

Published by Patrick Mutisya · 14 days ago

Cambridge A-Level Computer Science 9618 – 9.2 Algorithms

9.2 Algorithms – Using Suitable Identifier Names and Identifier Tables

1. Why identifiers matter

Identifiers are the names we give to variables, constants, arrays, functions and other data items in an algorithm. Good identifiers:

  • Make the purpose of the data clear.
  • Help the reader follow the logic without needing extra comments.
  • Reduce the chance of errors when the algorithm is translated into code.

2. Guidelines for choosing identifier names

  1. Be descriptive: Use words that convey the meaning, e.g. totalScore rather than ts.
  2. Use consistent case: CamelCase (totalScore) or snakecase (totalscore) – choose one style and stick to it.
  3. Avoid abbreviations unless universally known: avg for average is acceptable, but tp is ambiguous.
  4. Reflect the data type when helpful: Prefixes like num for integers, is for booleans, arr for arrays.
  5. Keep names reasonably short: Long names are hard to read; balance brevity with clarity.

3. The Identifier Table

An identifier table records every data item used by an algorithm together with its type and a short description. This table is a useful reference when designing, analysing, or debugging an algorithm.

IdentifierData TypeDescriptionExample \cdot alue
numStudentsintegerNumber of students in the class30
totalMarksintegerSum of all marks entered2150
averageMarkrealAverage mark = \$ \frac{totalMarks}{numStudents} \$71.7
passedCountintegerNumber of students whose mark ≥ 5024
isPassbooleanTrue if a particular student's mark ≥ 50True

4. Example: Calculating the Class Average

Consider the problem: “Given the marks of all students in a class, determine the average mark and how many students passed (mark ≥ 50).”

4.1 Step‑by‑step construction of the identifier table

  1. Identify the inputs: the list of marks.
  2. Identify the required outputs: averageMark and passedCount.
  3. Derive any intermediate data needed:

    • totalMarks – running sum of marks.
    • numStudents – count of marks processed.
    • isPass – temporary boolean for each mark.

  4. Choose appropriate data types (integer for counts, real for average, boolean for pass flag).
  5. Populate the identifier table (see the table above).

4.2 Pseudocode using the identifiers

INPUT marks[1 … n]

SET totalMarks ← 0

SET passedCount ← 0

SET numStudents ← n

FOR i ← 1 TO n DO

SET totalMarks ← totalMarks + marks[i]

IF marks[i] ≥ 50 THEN

SET passedCount ← passedCount + 1

END IF

END FOR

SET averageMark ← totalMarks / numStudents

OUTPUT averageMark, passedCount

5. Practice Exercise

Write an identifier table for the following problem statement:

“A library keeps a record of each book’s ISBN (a 13‑digit number), title, author, and whether it is currently on loan. Write an algorithm that counts how many books are on loan and lists the titles of books that are not on loan.”

After completing the table, draft a brief pseudocode outline that uses the identifiers you have chosen.

Suggested diagram: Flowchart showing the loop that checks each book’s loan status and updates the count and list.