awesome-everything RU
↑ Back to the climb

Base CS from zero

Data in memory: multiple-choice review

Crux Multiple-choice synthesis across the data-in-memory unit: contiguous layout, index arithmetic, named-field objects, and how references let a fixed-shape container hold variable-shape data.
Your altitude — climbing toward senior
ZeroJuniorMiddleSenior
You are at middle altitude — in the sky
◷ 13 min

Six questions that cut across the whole unit. None of them asks you to recite a definition — each asks you to reason about how data actually sits in memory and why the layout behaves the way it does.

Goal

Confirm you can connect the four ideas the unit built: equal-size contiguous cells, the index-to-address formula, named-field objects, and references that let a fixed grid hold variable-size things.

Quiz

An array of 8 numbers occupies one contiguous block of 32 bytes. Which statement about its layout is correct?

Quiz

Reaching arr[3000] takes the same time as reaching arr[3]. Why is array access constant time?

Quiz

Why is the first element of an array at index 0 rather than index 1?

Quiz

An array reaches a value by arr[2]; an object reaches a value by user.age. What is the core difference, and what follows from it?

Quiz

You have an array of 100 user objects, each a different size. How does it sit in memory while keeping the array's equal-size contiguous grid?

Quiz

Reading users[1].name in an array of objects takes two hops. What are they, and why two?

Recap

The through-line of the unit is one layered picture. An array is a contiguous run of equal-size cells, so any element’s address is one multiply and one add (base + i x element_size) — constant time, with index 0 forced by a zero offset. An object groups values by name instead of position, so its field order carries no meaning. And because a fixed-size cell cannot hold a variable-size object, cells hold references — equal-size addresses — letting a uniform grid point at variable-shape data elsewhere. Carried all the way, nested data is a graph of cells: some holding values, some holding addresses, wired together.

Continue the climb ↑Data in memory: free-recall review
shortcuts expand
search
K
prev piece
k
next piece
j
cycle tier
t
this menu
?
sources2
expand
  1. 01
  2. 02

Trademarks belong to their respective owners. Editorial reference only.