{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

Info icon This 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.
Image of page 1

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

View Full Document Right 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.
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern