1
Array
Data Structure
An array stores elements of the same type in contiguous memory. Access by index is O(1); inserting or deleting in the middle needs shifting, O(n).
Index-based access is O(1) because the address can be calculated
int arr[5] = {10, 20, 30, 40, 50};
int n = sizeof(arr) / sizeof(arr[0]); // length = 5
// insert 99 at index 2 (shift right)
int a[6] = {10, 20, 30, 40, 50};
for (int i = 5; i > 2; i--) a[i] = a[i - 1];
a[2] = 99; // 10 20 99 30 40 50
int m[2][3] = {{1, 2, 3}, {4, 5, 6}}; // 2D array