CodeIEB
Theory Notes/🗄️ Topic 4: Data & Information Management, Solution Development/12.4.3
12.4.3Grade 12

Dynamic Arrays & Combined Data Structures

Beyond fixed-size arrays — dynamic arrays and increasingly complex nested combinations of objects and arrays. Note: dynamic arrays are not examinable in the practical exam.

Dynamic array
An array-like structure that can grow or shrink in size during program execution, unlike a static array whose size is fixed when created (e.g. Java's ArrayList).
ComparisonStatic arrayDynamic array
SizeFixed at creation, cannot changeCan grow/shrink as needed at runtime
FlexibilityMust know the required size in advanceNo need to know the size in advance
Typical useWhen the number of elements is known/fixedWhen the number of elements varies or is unknown

Combining different data structure designs — these get progressively more complex and are common in a well-designed final PAT:

  • An array of objects where one field of the object is itself an array — e.g. a Learner object with an array of subject marks.
  • An array of inherited objects — e.g. an array declared as the superclass type, holding a mix of subclass objects.
  • An array of objects where one field is another object — e.g. an Order object with a Customer object as one of its fields.
  • An object where every field is an array of two different object types — a highly composed structure combining multiple relationships at once.

Example

public class Learner { private String name; private int[] subjectMarks; // array as a field private Address homeAddress; // another object as a field }

💡 Exam Tip

For the theory paper, focus on describing WHY you'd choose a given nested structure for a described scenario, rather than needing to code the most complex combinations from scratch — that level of implementation belongs to the PAT.