Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Array (data structure)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{short description|Type of data structure}} {{About|the byte-layout-level structure|the abstract data type|Array (data type)}} {{Use dmy dates|date=November 2020}} {{More citations needed|date=September 2008}} In [[computer science]], an '''array''' is a [[data structure]] consisting of a collection of ''elements'' ([[value (computer science)|values]] or [[variable (programming)|variables]]), of same memory size, each identified by at least one ''array index'' or ''key'', a collection of which may be a [[tuple]], known as an index tuple. An array is stored such that the position (memory address) of each element can be computed from its index tuple by a mathematical formula.<ref>{{cite web|url=https://xlinux.nist.gov/dads/HTML/array.html|title=array|last=Black|first=Paul E.|date=13 November 2008|work=[[Dictionary of Algorithms and Data Structures]]|publisher=[[National Institute of Standards and Technology]]|access-date=22 August 2010}}</ref><ref name="andres">{{cite arXiv |eprint=1008.2909 |author1=Bjoern Andres |author2=Ullrich Koethe |author3=Thorben Kroeger |author4=Hamprecht |title=Runtime-Flexible Multi-dimensional Arrays and Views for C++98 and C++0x |class=cs.DS |year=2010}}</ref><ref name="garcia">{{Cite journal|last1=Garcia|first1=Ronald |first2=Andrew |last2=Lumsdaine|year=2005|title=MultiArray: a C++ library for generic programming with arrays|journal=Software: Practice and Experience|volume=35|issue=2|pages=159β188|issn=0038-0644|doi=10.1002/spe.630|s2cid=10890293 }}</ref> The simplest type of data structure is a linear array, also called a one-dimensional array. For example, an array of ten [[32-bit]] (4-byte) integer variables, with indices 0 through 9, may be stored as ten [[Word (data type)|words]] at memory addresses 2000, 2004, 2008, ..., 2036, (in [[hexadecimal]]: <code>0x7D0</code>, <code>0x7D4</code>, <code>0x7D8</code>, ..., <code>0x7F4</code>) so that the element with index ''i'' has the address 2000 + (''i'' Γ 4).<ref>David R. Richardson (2002), The Book on Data Structures. iUniverse, 1112 pages. {{ISBN|0-595-24039-9}}, {{ISBN|978-0-595-24039-5}}.</ref> The memory address of the first element of an array is called first address, foundation address, or base address. Because the mathematical concept of a [[matrix (mathematics)|matrix]] can be represented as a two-dimensional grid, two-dimensional arrays are also sometimes called "matrices". In some cases the term "vector" is used in computing to refer to an array, although [[tuple]]s rather than [[vector space|vectors]] are the more mathematically correct equivalent. [[table (information)|Table]]s are often implemented in the form of arrays, especially [[lookup table]]s; the word "table" is sometimes used as a synonym of array. Arrays are among the oldest and most important data structures, and are used by almost every program. They are also used to implement many other data structures, such as [[list (computing)|list]]s and [[string (computer science)|string]]s. They effectively exploit the addressing logic of computers. In most modern computers and many [[external storage]] devices, the memory is a one-dimensional array of words, whose indices are their addresses. [[Central processing unit|Processors]], especially [[vector processor]]s, are often optimized for array operations. Arrays are useful mostly because the element indices can be computed at [[Run time (program lifecycle phase)|run time]]. Among other things, this feature allows a single iterative [[statement (programming)|statement]] to process arbitrarily many elements of an array. For that reason, the elements of an array data structure are required to have the same size and should use the same data representation. The set of valid index tuples and the addresses of the elements (and hence the element addressing formula) are usually,<ref name="garcia" /><ref name="veldhuizen">{{cite conference |first1=Todd L. |last1=Veldhuizen |title=Arrays in Blitz++ |publisher=Springer |location=Berlin |conference=Computing in Object-Oriented Parallel Environments |date=December 1998 |isbn=978-3-540-65387-5 |pages=223β230 |series=Lecture Notes in Computer Science |volume=1505 |doi=10.1007/3-540-49372-7_24 }}{{dead link|date=November 2023}}</ref> but not always,<ref name="andres" /> fixed while the array is in use. The term "array" may also refer to an [[array data type]], a kind of [[data type]] provided by most [[high-level programming language]]s that consists of a collection of values or variables that can be selected by one or more indices computed at run-time. Array types are often implemented by array structures; however, in some languages they may be implemented by [[hash table]]s, [[linked list]]s, [[search tree]]s, or other data structures. The term is also used, especially in the description of [[algorithm]]s, to mean [[associative array]] or "abstract array", a [[theoretical computer science]] model (an [[abstract data type]] or ADT) intended to capture the essential properties of arrays.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)