Two software libraries implement the basic mutable Map ADT for the same key and value types, using the same key equality rule. Their documentation adds no ordering or running-time guarantees. Which statements are guaranteed by the Map ADT? Select all that apply.
Every conforming implementation visits entries in their insertion order.
Every conforming implementation completes each lookup in constant time.
Maps with exactly the same key–value bindings have equal sizes.
Removing one stored key preserves all other keys' associated values.
Unlock full course notes by signing up
Zero seats or a missing key
A map of available seats initially contains K2 → 0 and M7 → 18. Keys use exact string equality, and stored values are nonnegative integers.
For this interface, get returns the stored value or the special marker absent. put stores the supplied value and returns the previous value, or absent for a new key. remove returns the removed value, or absent if the key was missing. containsKey returns true or false.
Complete the result column by applying the operations from top to bottom. Enter exact integers or the words true, false, or absent. Each row asks for the operation's returned result.
Accumulating parcels by destination
A warehouse records batches of parcels sent to three destinations. An initially empty map, totals, associates each destination with its accumulated number of parcels.
For each batch, the program performs these operations in order:
Here, getOrDefault returns the stored value when the key exists and otherwise returns the supplied default without changing the map. put inserts an association or replaces its existing value.
How key equality changes the result
A test registry maps string keys to integer counts of available spaces. Apply the seven operations in the figure to an initially empty map, separately under each policy:
Exact policy: keys are equal only when every character, including capitalization, matches.
Ignore-case policy: capitalization is ignored when comparing keys.
Following employee-to-role-to-rate lookups
A repair company calculates labour charges using three maps. Employee identifiers are exact string keys, and every lookup needed below succeeds.
For each employee, the program looks up the employee's role, uses that role as a key in the rate map, and multiplies the resulting rate by the employee's recorded hours. The total labour charge is the sum across all four employees. Ignore taxes and additional fees.
Find both quantities below in USD, to two decimal places: