Machine-translated by Google. Questions are authored in English.
Top

Discussion

A ring buffer declared with 16 slots and the one-empty-slot convention can hold at most

  • A.17 items
  • B.15 items
  • C.16 items
  • D.8 items

Answer: B

One slot is given up so that full and empty remain distinguishable, so fifteen is the usable capacity. Sizing the array to a power of two lets the index wrap by a mask rather than a division, which is why sixteen was chosen.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.