Page 52 - DCAP201_FUNDAMENTALS_OF_DATA_STRUCTURES
P. 52

Anil Sharma, Lovely Professional University                                              Unit 4: Arrays





                                       Unit 4: Arrays                                           Notes


             CONTENTS
             Objectives

             Introduction
             4.1  Linear Arrays
                 4.1.1   Representation of Linear Arrays

                 4.1.2   Traversing Linear Arrays
             4.2  Multidimensional Arrays
                 4.2.1   Two-Dimensional Arrays

                 4.2.2   Representation of Two-Dimensional Arrays
             4.3  Summary
             4.4  Keywords

             4.5  Review Questions
             4.6  Further Readings

          Objectives

          After studying this unit, you will be able to:

               Discuss the concept of linear and multi-dimensional arrays
               Explain the representation of linear arrays
               Discuss the representation of multi-dimensional arrays

          Introduction

          A data structure is the way data is stored in the machine and the functions used to access that
          data. An easy way to think of a data structure is a collection of related data items. An array is a
          data structure that is a collection of variables of one type that are accessed through a common
          name. A specific element is accessed by an index. A C-style array is aggregate data type. Array
          can hold multiple values of a single type. Elements are referenced by the array name and an
          ordinal index. Each element is a value, index pair, the what, where duo. Indexing begins at zero.
          The array forms a contiguous list in memory. The name of the array holds the address of the first
          array element. We specify the array size at compile time, often with a named constant.

          4.1 Linear Arrays

          The simplest form of array is a one-dimensional array that may be defined as a finite ordered set
          of homogeneous elements, which is stored in contiguous memory locations.

                 Example: an array may contain all integers or all characters or any other data type, but
          may not contain a mix of data types.





                                           LOVELY PROFESSIONAL UNIVERSITY                                   45
   47   48   49   50   51   52   53   54   55   56   57