EvaluationUsing 1D arrays to store data

Appropriate use of coding constructs is evaluated to determine the efficiency of software as it relates to use of RAM. Software is measured against the functional requirements to evaluate fitness for purpose.

Part ofComputing ScienceSoftware design and development

Using 1D arrays to store data

Here are two examples of code written in Reference Language that will allocate ten locations in main memory (RAM) to be used to store the names of ten cities.

Table showing efficient (DECLARE city AS ARRAY OF STRING INITIALLY [" "] * 10) and inefficient (DECLARE city1 AS STRING INITIALLY " ") arrays

In the inefficient example, ten different variables are declared individually. This requires much more code to be written and is less efficient than creating an array capable of storing ten elements.