[2-min Computer Science Concepts] What are Arrays?

Do you know the matrix movie? A matrix is a data structure that holds a bunch of data items of the same type. For example, a matrix of integers holds a set of numbers.
An array is the exact same thing as a matrix. In fact, a matrix is nothing but an array, or an array of arrays, or an array of arrays of arrays, or so on. Most programming languages store the array very efficiently in memory. For example, all integers lie in the same memory region.
You can access each element in the array via indices. The index of the first array element is 0. The index of the second element is 1. The index of the i-th element is i-1.
In practice, you have to decide whether to use a linked list or an array to store a sequence of data values. Use arrays when you need fast access to elements and lists when you dynamically need to grow or shrink the sequence.

Leave a Comment

Your email address will not be published. Required fields are marked *