Array
A fixed-size, contiguous block of memory storing elements of the same type. Provides O(1) access by index and O(n) for insertion/deletion.
Syntax
dsa
// Most languages:
Type[] arr = new Type[size];
arr[index]Example
dsa
// JavaScript:
const arr = [1, 2, 3, 4, 5];
console.log(arr[2]); // O(1) access: 3
arr.push(6); // O(1) amortized
arr.splice(2, 1); // O(n) deletion
// Time complexity:
// Access: O(1), Search: O(n), Insert/Delete: O(n)