HomeToolsAbout a20k

Array

Why is Array Lookup O(1)

In an array, index of 0 (base address) has a memory address.

  • Multiplying the n-th index number and size of one element, you get a memory offset value
  • When you add the offset value to the base address, we can fetch the memory address of the n-th index value

This way, you don't have to iterate through the array and the lookup time becomes O(1).

© VincentVanKoh