array
An array is the simplest way to store a group of items of the same type: a single block of memory holding them one after another, like a row of identical mailboxes numbered 0, 1, 2, and so on. Because every item is the same size and they sit side by side, the computer can jump straight to item number i — its address is just the start of the block plus i times the item size. There is no searching and no walking through the others.
That single fact gives the array its superpower: reading or writing array[i] takes O(1) time, no matter how big the array is or where i lands. The cost shows up elsewhere. The size is usually fixed when the array is created, so growing it means allocating a new block and copying everything over. Inserting or deleting in the middle means shifting all the items after that spot to keep them contiguous, which is O(n) in the worst case.
Arrays are the foundation almost everything else is built on — strings, dynamic arrays, stacks, queues, hash tables and heaps all use an array underneath. When you need fast indexed access and you know roughly how many items you have, the plain array is hard to beat.
int a[5] = {10, 20, 30, 40, 50};
// index: 0 1 2 3 4
// +----+----+----+----+----+
// | 10 | 20 | 30 | 40 | 50 |
// +----+----+----+----+----+
int x = a[3]; // O(1): jump straight to slot 3 -> 40
a[1] = 99; // O(1) write
// inserting before index 1 would shift 20,30,40,50 right: O(n)Indexed access is O(1); the layout is just one flat block of memory.
Most languages index arrays from 0, so a length-n array uses indices 0 to n-1. Reading past the end is a classic, dangerous bug.