awesome-everything RU
↑ Back to the climb

Base CS from zero

Memory: multiple-choice review

Crux Multiple-choice synthesis across the memory unit: addresses vs values, byte-addressing, pointers and dereferencing, and stack vs heap lifetimes.
Your altitude — climbing toward senior
ZeroJuniorMiddleSenior
You are at middle altitude — in the sky
◷ 13 min

Six questions that pull the whole unit together. None of them is a definition to recite — each asks you to combine two or three ideas (address vs value, the byte, pointers, stack vs heap) and reason about what the machine actually does.

Goal

Confirm you can connect the unit’s core ideas: a cell has both an address and a value, the byte is the addressable unit, a value can itself be an address (a pointer), and the stack and heap are two regions of the same memory with different lifetimes.

Quiz

A cell at address 7 holds the value 7. Which statement is correct?

Quiz

A program stores a 32-bit integer in byte-addressed memory starting at address 100. Which addresses does it occupy, and why?

Quiz

Cell at address 5 holds value 12. Cell at address 12 holds value 99. A program dereferences the pointer at address 5. How many memory reads happen, and what is the final result?

Quiz

Why does indirection through a pointer appear in almost every non-trivial program, given that it costs an extra memory read?

Quiz

Function main calls a, which calls b. While b is running, a creates a large object on the heap and keeps a pointer to it. b returns, then a returns. What is true about memory afterward?

Quiz

A recursive function with no base case keeps calling itself and the program crashes with a stack overflow. What actually happened, in terms of the unit's model?

Recap

The through-line of this unit is one model: memory is a row of byte-addressed cells; every cell has a fixed address and a changeable value; a value can itself be an address, which is what makes a pointer, and following it (dereferencing) costs one extra read; and the same physical memory is split into a LIFO stack whose frames live exactly as long as their function and a heap whose objects can outlive any call. Every question above resolves back to telling address from value, and lifetime from location.

Continue the climb ↑Memory: free-recall review
shortcuts expand
search
K
prev piece
k
next piece
j
cycle tier
t
this menu
?
sources3
expand
  1. 01
  2. 02
  3. 03

Trademarks belong to their respective owners. Editorial reference only.