Physics I / Lists, arrays, and structured storage
Practice question · True or false

Accessing an element by index in an array takes O(n) time.

Hints
  1. Ask whether the machine has to walk the list or can jump straight in.
  2. An address computed by arithmetic takes the same time whatever the size.
Show the answer

False

Why

Direct index access is O(1) because the address is computed from the base pointer.

Read the lesson: Lists, arrays, and structured storage →

Practise Lists, arrays, and structured storage

The app has 6 more questions on this lesson, and keeps your place in the course. Physics I is free to start.

More questions on Lists, arrays, and structured storage