Linear Lists

A linear list is the simplest of data structures.  It is, as the name suggests, nothing more than a list of data items.

Array Variables

A linear list can be implemented using a one dimensional array variable.  An array variable is a named group of contiguous memory locations in the RAM.

array1

Individual elements of an array can be accessed by means of an index number.  Arrays are normally manipulated using iteration constructs.

From a programmer’s point of view, a one dimensional array is a list.  An array contains a number of elements into which items of data can be placed.  Each element has an index number.

array2

To declare an array, for example in Visual Basic.NET, you need to specify its name, size (unless it is a dynamic array) and a data type.  An array declared with a type of Object can hold mixed data types.

Dim People(4) As Integer

The size you specify for an array governs how many elements it will have. To declare an array with 5 elements, you need to specify a size of 4, because counting starts at zero.  Arrays are said to be zero based.

To access an element of the array, for example to assign a value to it, or to change its contents, you can refer to the element by its index number.

People(2) = “kevin”

array3

Typically, an array variable is used to store related data items, and a programmer will want to access each of them in turn, perhaps to search for a particular item.  That’s what arrays are normally manipulated with iteration constructs such as DO while and FOR NEXT loops.

FOR i = 0 TO 4

       OUTPUT People(i)

NEXT i