Content deleted Content added
Added some info on growable arrays and some sections |
No edit summary |
||
Line 17:
Although useful in their own right, arrays also form the basis for several more complex data structures, such as [[heap]]s, [[hash table]]s, and [[vlist (computer science)|vlist]]s, and can be used to represent [[string]]s, [[stack]]s and [[queue]]s. They also play a more minor role in many other data structures. All of these applications benefit from the compactness and locality benefits of arrays.
One of the disadvantages of an array is that it has a single fixed size, and although its size can be altered in many environments, this is an expensive operation. <i>Growable arrays</i> or <i>dynamic arrays</i> are arrays which automatically perform this resizing as late as possible, when the programmer attempts to add an element to the end of the array and there is no more space. To average the high cost of resizing over a long period of time (we say it is an [[amortized analysis|amortized cost]]), they expand by a large amount, and when the programmer attempts to expand the array again, it just uses more of this reserved space.
In the [[C programming language]], one-dimensional [[character (computing)|character]] arrays are used to store null-terminated [[string]]s, so called because the end of the string is indicated with a special reserved character called a [[null character]] ('\0').
|