Abstract Data Types & Arrays
Abstract Data Type: A data type created by the programmer themselves.
Tuple: A data structure that is immutable/unchangeable and in sorted order.
Records: A data structure where there is a fixed number of variables, each one is called a field and they each have an
identifier called a field name and a data type. Each field in a record can have a different data type, e.g. character, string,
integer, bool, real/float.
Array:
A data structure that holds a number of data items or elements of the same data type.
An array can be declared using a single identifier and can be used efficiently using iteration.
Each position in an array is identified by an index, the first item in an array is at index 0.
The contents of an array is stored next to each other in the sequence given, in main memory. Therefore each position in
the array can be accessed directly, this is good for high performance algorithms and such.
Values stored in an array are mutable, therefore they can be changed while the program is running like a list and unlike a
tuple.
There are 1D, 2D and 3D Arrays:
This is a 1D array, it can be visualized as a single row of values.
ARRAY spelling_words[10] #Declare an array of 10 elements
spelling_words[0] = "path"
spelling_words[1] = "floor"
spelling_words[2] = "sugar"
spelling_words[3] = "because"
spelling_words[4] = "beautiful"
spelling_words[5] = "clothes"
spelling_words[6] = "whole"
spelling_words[7] = "behind"
Abstract Data Types & Arrays 1