A retailer keeps one current stock record for every combination of warehouse identifier and product code. Each warehouse holds many products, and the same product can be held at several warehouses. An application stores these records in a map keyed only by product code. When another warehouse's record for the same product is assigned to that key, the earlier value is replaced. The application needs direct lookup of one warehouse's stock record for one product. Which revision best meets that need without losing the separate records?
Use the pair of warehouse identifier and product code as the key for each stock record.
Use warehouse identifier as the key and store one product's stock record as its value.
Keep product code as the key and add the warehouse identifier as a field in its value.
Use the current stock quantity as the key and store the warehouse and product in its value.
Unlock full course notes by signing up
Choosing an undo structure
A project application records enough information to reverse each edit. A user creates a note, changes the due date, and then renames the project. Each press of Undo must reverse the most recent edit that has not already been undone. Which structure's standard access rule best matches this requirement?
Updating an indexed customer list
A scheduling application stores customer names in an array with space for seven names. Initially, four positions are occupied in this order: Mira, Owen, Priya, Sami. Unused positions follow the occupied positions.
An index is the number identifying a position. Indexing starts at 0, so Mira initially occupies index 0.
Apply these operations in the stated order:
Designing consistent request handling
A repair business is designing a service-request application. Every request receives a unique text identifier. One customer may submit several valid requests. Staff need to find a request by its identifier, and active requests must be assigned in arrival order. A request can be cancelled before assignment. A separate tracking feature must remember whether a particular request has already received its confirmation message.
Recommend a structure for each of the following and explain your choices:
The details of one request and lookup across all requests.
Reorganizing a category hierarchy
An online retailer stores its product categories in a rooted tree, with Catalogue as the root. A leaf is a category with no children. A category's depth is the number of parent–child connections on the path from Catalogue to that category.
Apply these two changes in order:
Move Audio and all its descendants from Electronics to Kitchen, making Audio an immediate child of Kitchen.