06-ArrayADT - 1 Array Abstract Data Type Gunnar Gotshalks...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Array Abstract Data Type Gunnar Gotshalks 2007 December Table of Contents What this module is about . ....................................................................................................... 1 Introduction . ............................................................................................................................... 2 Data type objects . ...................................................................................................................... 3 Array elements .................................................................................................................... 3.1 Sub -arrays .......................................................................................................................... 3.2 Array descriptor ................................................................................................................... 3.3 Data type operations . ................................................................................................................ 4 Enquiry operations .............................................................................................................. 4.1 Read operations .................................................................................................................. 4.2 Write operations .................................................................................................................. 4.3 Sparse array operations ...................................................................................................... 4.4 Array memory allocation methods . ......................................................................................... 5 Row and column storage .................................................................................................... 5.1 General formula to compute the address of an array element ............................................ 5.2 Sparse arrays ...................................................................................................................... 5.3 1 What this module is about This module contains a description of the array data type and some discussion as to how we allocate memory space to arrays. The value of defining arrays as an abstract data type is primarily for systems programmers, who work behind the scenes and bring you all the wonderful software that comes with an operating system, such as compilers, linkers, file managers, text editors, etc. For most of us mortal people, we simply use arrays in our programming languages without thought of the more abstract nature of arrays. We do not go into detailed program implementations. 2 Introduction The array data type is the simplest structured data type. It is such a useful data type because it gives you, as a programmer, the ability to assign a single name to a homogeneous collection of instances of one abstract data type and provide integer names for the individual elements of the collection. You, the programmer, can then compute the name of a specific element and avoid the need for explicitly declaring a unique name for each array element. Consider how difficult it would be to program if you had to declare explicitly a separate name to each array element and use such names in your programs. Because the names of array elements are computed, the computer requires a means of finding < at execution time < the physical storage location corresponding to an array element from the index, or name, of the array element. As a consequence, not only do we require space for the array elements themselves, but we also require space for an array descriptor which is used at execution time to map array indices to memory addresses. The array descriptor contains the size of the array elements, the number of dimensions and bounds of each dimension.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 Array ADT NOTE: In fact, for all data types beyond the primitive data types we require data descriptors. One could even define the primitive data types as those data types which do not require data descriptors. If you reflect on the declaration section of any programming language, you will find that the non primitive data types have complex definitional parameters. These definitional parameters correspond to the information required in the data descriptors. To make it easy to compute the memory address of an array element and to make memory management simple, we have the restriction that each element of the array must be of the same type, so that each array element can be allocated a pre ï defined and equal amount of memory space.
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/14/2012 for the course CSE 3214 taught by Professor Ross during the Winter '12 term at York University.

Page1 / 8

06-ArrayADT - 1 Array Abstract Data Type Gunnar Gotshalks...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online