Wednesday, April 29, 2020

Parallel Arrays free essay sample

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. We will write a custom essay sample on Parallel Arrays or any similar topic specifically for you Do Not WasteYour Time HIRE WRITER Only 13.90 / page 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 paging nd processor caching algorithms (since they generally have poor locality of reference). In some cases, linked data structures may also use more memory (for the link fields) than competing array structures. This is because linked data structures are not contiguous. Instances of data can be found all over in memory, unlike arrays. In some theoretical models of computation that enforce the constraints of linked structures, such as the pointer machine, many prob lems require more steps than in the unconstrained random access machine model.