Log in Sign up
Back to Discover
💻

Array (data structure)

technology Maturity 11-13

A computer uses lists.

1D array diagram.svg
1D array diagram.svg
These lists hold many things. Each thing has a spot. You can find things fast. This helps your computer work. It is very helpful. Can you find a list?

36 words

Computers use special lists.

1D array diagram.svg
1D array diagram.svg
These lists are called arrays. An array holds many things of the same size. Each thing has a special number. This number is called an index.
2D array diagram.svg
2D array diagram.svg
You use the index to find a thing. Some arrays are long lines. Other arrays look like grids. These are called two-dimensional arrays. They can have many rows and columns.
3D array diagram.svg
3D array diagram.svg
Computers use arrays for almost every job. They help programs work very fast.

82 words

Computers use special lists called arrays.

1D array diagram.svg
1D array diagram.svg
An array is a collection of items. These items are all the same size. Each item has a number to identify it. We call this number an index.
2D array diagram.svg
2D array diagram.svg
You can use the index to find an item quickly. This is possible because of a math formula. The computer knows the starting spot, called the base address. It uses the index to calculate exactly where each item sits in memory.

Some arrays are simple lines. We call these one-dimensional arrays. Other arrays look like grids. These are two-dimensional arrays, or matrices.

3D array diagram.svg
3D array diagram.svg
You can even have three-dimensional arrays. These use three indices to find an item.

Many programs use arrays every day. They help make lists and strings. They are also used to build databases. Arrays are very important. They help computers work in a fast and efficient way. Most modern computers use arrays to manage their memory.

161 words

An array is a very important tool in computer science. It is a way to organize a collection of items in a computer's memory.

1D array diagram.svg
1D array diagram.svg
These items are called elements. Every element in an array must be the same size. They also use the same type of data. This makes the array a linear collection. Because they are so organized, almost every computer program uses them. They are used to build other things like lists and strings.

Arrays work using a special math formula.

2D array diagram.svg
2D array diagram.svg
Each element has a specific position called an index. You can think of an index like a house number on a street. To find an element, the computer looks at the base address. The base address is the starting spot in the memory. The computer then uses the index to calculate the exact address of any item. This allows the computer to find data very quickly during a program.

Computers have used arrays since the very beginning.

3D array diagram.svg
3D array diagram.svg
Early digital computers used them for math and data tables. In 1945, John von Neumann wrote the first program to sort an array. This was called a merge sort. Later, new programming languages were made to help with arrays. FORTRAN was made in 1957 to support multi-dimensional arrays. C was also created later, in 1972, and it is still very important today.

There are different ways to shape an array. A one-dimensional array is just a single line of items. A two-dimensional array looks like a grid with rows and columns. These grids are often called matrices.

Row and column major order.svg
Row and column major order.svg
You can even have three-dimensional arrays. In a two-dimensional array, you use two indices to find an item. For example, you might pick the second row and fourth column. The number of indices you need is called the dimension or rank.

Many things you use every day rely on arrays. They help run large databases that store lots of records. They are also used to make mathematical vectors.

Array of array storage.svg
Array of array storage.svg
Even the memory in your modern computer works like a huge array. Some languages use zero-based indexing. This means the very first item is at index 0. This is a design choice used by languages like Java and Lisp. Arrays help make sure computers stay fast and efficient.

387 words

In computer science, an array is a fundamental data structure. It consists of a collection of elements, which can be values or variables. Every element in an array must have the same memory size and data type. This uniformity allows the array to be a mutable and linear collection. Arrays are essential because they allow computers to organize and access data very efficiently. Almost every computer program uses them to manage information.

1D array diagram.svg
1D array diagram.svg

The way an array works is based on mathematical precision. Each element is identified by at least one array index, also known as a subscript. To find an element, the computer uses a specific formula to compute its memory address. This calculation starts from the base address, which is the starting position of the array in memory. For a one-dimensional array, the computer uses the index to find the exact location. If you have an array of ten 32-bit integers starting at address 2000, the element at index i is found at address 2000 + (i × 4). This mathematical link between the index and the address makes arrays incredibly fast for computers to process.

Arrays can take several different shapes or dimensions. A one-dimensional array is a simple linear list of items. A two-dimensional array forms a grid with rows and columns, often called a matrix. You can even have three-dimensional arrays, which add depth to the grid.

2D array diagram.svg
2D array diagram.svg
The number of indices required to find a specific element is known as the dimension, dimensionality, or rank. For example, a two-dimensional array requires two indices, like a row and a column number. A three-dimensional array would require three indices to locate a single piece of data.
3D array diagram.svg
3D array diagram.svg

The history of arrays is tied to the birth of digital computing. Early computers used machine-language programming to manage arrays for math and data tables. In 1945, John von Neumann wrote the first array-sorting program, known as a merge sort. This happened while the first stored-program computers were being built. Over time, programming languages evolved to make arrays easier to use. FORTRAN, created in 1957, provided support for multi-dimensional arrays. C, released in 1972, also included this support. Later, C++ introduced class templates in 1983 to handle arrays with dimensions fixed at runtime.

Different programming languages use different rules for numbering their indices. This is known as the indexing system. In zero-based indexing, the first element is at index 0. This is a popular design choice used by influential languages like C, Java, and Lisp. It works well because the index acts as an offset from the starting position. Other systems use one-based indexing, where the first element is index 1. Some languages, like Fortran 90 or Pascal, even allow users to choose their own starting index.

Row and column major order.svg
Row and column major order.svg

Arrays are used for many complex tasks in modern technology. They are used to implement other data structures, including lists, strings, stacks, and queues. Large databases often use one-dimensional arrays to store records. In mathematics, arrays are used to represent vectors and matrices. They can even be used to control the flow of a program through control tables. This allows a program to follow different paths based on the values stored in the array. Because they are so space-efficient, they are often used to emulate dynamic memory allocation in a program.

To manage these complex structures, computers often use a "dope vector." This is a record that contains the array's descriptor. It packs together important details like the dimension, the base address, and the address increments. It may also include the size of each element and the allowed range for indices. By manipulating the dope vector, a computer can perform tasks like slicing a sub-array or reversing the order of elements very quickly. This makes the array a powerful and flexible tool for both programmers and the machines they use.

Array of array storage.svg
Array of array storage.svg

649 words
🖼️ Images & Media (5)
File:1D array diagram.svg
1D array diagram.svg
File:2D array diagram.svg
2D array diagram.svg
File:3D array diagram.svg
3D array diagram.svg
File:Row_and_column_major_order.svg
Row_and_column_major_order.svg
File:Array of array storage.svg
Array of array storage.svg
Up Next
💻
Data structure
Technology
More to explore

What is Nepedia?

A free, ad-free encyclopedia for children. Every article is written at five reading levels, so the same page works for a five-year-old and a fifteen-year-old — use the level switcher above to see this one change. No account needed to read.