What does "contiguous placement of elements" in memory mean?
Contiguous placement of elements means that all array elements are stored in memory one after another, with no gaps - that is, their cells go one after another in sequential order.
1. What this looks like
Picture memory as a long tape of addresses:
Addresses: 1000 1004 1008 1012 1016
Elements: [10] [20] [30] [40] [50]If the size of one element is 4 bytes, then:
- the first element (
A[0]) is at address 1000, - the second (
A[1]) is at 1004, - the third (
A[2]) is at 1008, and so on.
There are no "empty spots" between them, this is what contiguity means.
2. Why this matters
- The computer can instantly calculate the address of any element:
address = start + (index × element size). - This makes index access very fast, O(1).
- It's convenient for the processor to load such data into cache, because it "sits next to itself".
3. How it differs from lists
In linked lists, elements sit in different places in memory and are connected by references. So to reach the needed one, you have to go through all the previous ones.
[10|→] [20|→] [30|→] [40|None]
(addresses can be random)4. Downside of contiguous placement
For an array to grow, a large contiguous block of memory must be allocated in advance. If there is no room next to it, a new block has to be created and the whole array copied over.
Summary:
"Contiguous placement" means all array elements sit one after another in memory, with no gaps. Thanks to this, an array provides instant index access and high performance.
Short Answer
Interview readyA concise answer to help you respond confidently on this topic during an interview.