A school supply application represents a shipment manifest using a hidden storage structure. You interact with each manifest only through these specified operations:
Manifest M initially records 18 notebooks. Name A is an alias for M: both names refer to the same manifest. Name C refers to the independent manifest returned by copy(M).
The application then performs these actions in order:
A previously returned integer does not update when a manifest changes. Find the final values returned by count(M) and count(C), and the final value of saved. Give each as a whole-number count of notebooks.
Unlock full course notes by signing up
Pass one procedure's result into another
A delivery tracker provides two procedures with no side effects:
total_minutes(hours, minutes) accepts whole-number hours from 0 through 23 and minutes from 0 through 59. It returns 60 * hours + minutes, measured in minutes after midnight.
delay_minutes(planned, actual) accepts two times measured in minutes after midnight. It returns actual - planned, so a positive result means late arrival.
Read the behavior at packet boundaries
A seed-packing program uses full_packets(items, packet_size). It accepts a nonnegative whole number of seeds and a positive whole-number packet size. It returns the number of completely filled packets that can be made; leftover seeds do not count as another packet. The procedure does not change either argument or produce other visible effects.
Complete the return-value table for packets holding six seeds. Enter exact integers in all answer cells.
Read abstract values from different encodings
A monitoring component stores the set of active sensors among sensor IDs 101, 102, 103 and 104. Its public operations are countActive(), which returns the number of active sensors, and isActive(id), which returns whether the specified sensor is active.
Two internal encodings are supported:
Flags: four entries correspond, in order, to IDs 101, 102, 103 and 104. An entry of 1 means active; 0 means inactive.
Which replacements preserve the abstraction?
A checkout program calls rebate_cents(p), where p is any nonnegative integer purchase amount in cents. The procedure returns p // 10 cents. Here, // means whole-number division with the remainder discarded, and % gives the remainder. The procedure prints nothing and makes no changes outside its local calculation. No execution-speed requirement is specified.
Which proposed replacements preserve the specified behavior for every accepted input? Select all that apply.