Parallel Arrays

Only available on StudyMode
  • Topic: Array data structure, Algorithmic efficiency, Allocation
  • Pages : 2 (427 words )
  • Download(s) : 135
  • Published : May 17, 2013
Open Document
Text Preview
Parallel arrays and arrays of structures

An array of structures are usually equivalent to parallel arrays of the components. For example, if each student record consists of an ID number and a GPA value, then a list of students can be represented as an array of structure: The same data can be stored as two arrays that "parallel" to each other, in the sense that the same index in them indicate data for the same student: Usually the first way is more natural and convenient.

Advantages and disadvantages
Against Arrays

Compared to arrays, linked data structures allow more flexibility in organizing the data and in allocating space for it. With arrays, we must choose a size for our array once and for all; this can be a potential waste of memory. A linked Data structure is built dynamically and never needs to be bigger than the programmer requires. It also requires no guessing in terms of how much space you must allocate when using a linked data structure. This is a feature that is Key in saving wasted memory. The nodes of a linked data structure can also be moved individually to different locations without affecting the logical connections between them, unlike arrays. With due care, a process can add or delete nodes to one part of a data structure even while other processes are working on other parts. On the other hand, access to any particular node in a linked data structure requires following a chain of references that stored in it. If the structure has n nodes, and each node contains at most b links, there will be some nodes that cannot be reached in less than log b n steps. For many structures, some nodes may require worst case up to n -1 steps. In contrast, many array data structures allow access to any element with a constant number of operations, independent of the number of entries.

General Disadvantages
Linked data structures also may also incur in substantial memory allocation overhead (if nodes are allocated individually) and frustrate memory...
tracking img