Site Tools


array

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
array [June 11, 2026 at 09:42] – created - external edit 127.0.0.1array [August 22, 2026 at 15:22] (current) – external edit 127.0.0.1
Line 1: Line 1:
 # Array # Array
-An **array** is a fixed-size sequence of elements of the same type stored in contiguous memory. The index of an element determines its address: `base + index * sizeof(element)`. This means any element is reachable in O(1) time without traversal, and the memory layout is cache-friendly — iterating over an array touches sequential cache lines rather than chasing pointers.+An **array** is a fixed-size sequence of elements of the same type stored in contiguous memory. 
 + 
 +The index of an element determines its address: `base + index * sizeof(element)`. This means any element is reachable in O(1) time without traversal, and the memory layout is cache-friendly — iterating over an array touches sequential cache lines rather than chasing pointers.
  
 ```c ```c
Line 13: Line 15:
  
 | Operation | Time | | Operation | Time |
-|---|---| 
 | Access by index | O(1) | | Access by index | O(1) |
 | Search (unsorted) | O(n) | | Search (unsorted) | O(n) |
array.1781170938.md.gz · Last modified: by 127.0.0.1