DEV Community

Cover image for Just an array???
Sakshi
Sakshi

Posted on

Just an array???

In this post, we'll not see syntax, code and any algorithm.

It is just you and these arrays.

Ok, so we know how to store individual numbers. Let's talk about storing several numbers.

What is array?

RAM is basically an array already.

It is a linear data structure, stores elements in contigous manner.

Each item in the array is the same size (takes up the same number of bytes).
The array is uninterrupted (contiguous) in memory. There can't be any gaps in the array...like to "skip over" a memory slot Spotify was already using.

address of nth item in array=

address of array start + (n∗size of each item in bytes)

Arrays have fast lookups (O(1) time), but each item in the array needs to be the same size, and you need a big block of uninterrupted free memory to store the array.

Thanks for reading
In this blog we were only discussing what exactly the array is, thatswhy not included its types, syntax and drawbacks.

Top comments (0)