Nepedia
Back to Discover
Fluent Reader
💻

Array (data structure)

technology Maturity 11-13 Next article →

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
1D array diagram

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
2D array diagram

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
3D array diagram

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
Row and column major order

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
Array of array storage

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.

380 words

Where will your curiosity go next?

Keep exploring at your chosen reading level.

🖼️ 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
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.