Budgeting independent snapshots

A laboratory application keeps editable snapshots of a measurement record. An independent snapshot is a deep copy that shares no mutable object with the source or with another snapshot.


The source consists of one record object, one readings array, one notes array, and four distinct mutable note objects. Each note appears once in the notes array. There are no other referenced objects. The readings array stores 40 numeric values directly; the notes array stores four references.


Use this exact storage model:


Component

Storage

Record object, including its two reference fields

40 bytes

Array header

24 bytes per array

Numeric array entry

8 bytes

Reference array entry

8 bytes

Note object, including all its contents

32 bytes


Every deep copy duplicates all these objects. A shallow copy duplicates only the record object. Ignore temporary working storage, alignment, and bookkeeping outside the listed objects. The original record is already stored and does not count against the snapshot budget.


With exactly 20000 bytes available for snapshots, find the maximum number of independent snapshots that can be retained simultaneously and the unused storage after retaining that many. Give both answers as exact integers; report unused storage in bytes.

Your answers

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Shallow vs Deep Copies Questions: