Embercode
✕
Pointers and Memory AddressesQuick quiz

Cache

6 questions. Covers Cache locality.

Questions 1 to 5 of 6

  1. 1. A linked list of 1,000,000 nodes with random links and an array of 1,000,000 ints are each walked once. With 16 ints in each 64-byte cache line, about how many cache-line loads does the array walk need?
  2. 2. Walking a linked list of n nodes once takes O(n) steps, the same count as an array walk. Why is each step of a randomly linked list so expensive, according to the lesson?
  3. 3. Why does a loop over an array run faster than a loop over a linked list of the same length?
  4. 4. On the test machine, the array row went from 0.22 ns per item at -O2 to about 3 ns at -O0, while the random list stayed near 130 ns. Which explanation fits the lesson?
  5. 5. A linked list whose nodes are linked in random order is walked with p = p->next. True or false: the processor cannot start loading the next node until the current node's next pointer has arrived.

5 question(s) left on this page.