Free practice · ordering · medium

Practice

Review collection processing

Order a safe review for collection-processing code.

Collection contract

Choose access by the relationship the data represents

List
Ordered items accessed by index or iteration
Dictionary
Values accessed by stable keys
Boundary
Empty, one-item, and several-item states
Mutation
One deliberate, traceable change
Reconciliation
Expected size, keys, counts, and totals

Lists use ordered positions; dictionaries use meaningful keys. Both need shape, missing-data, mutation, and boundary checks.

Arrange in the correct order
  1. 1. Verify empty, one-item, and malformed cases
  2. 2. Reconcile expected and actual size, keys, and totals
  3. 3. Trace reads and controlled mutations
  4. 4. Choose index, key, or iteration deliberately
  5. 5. Confirm what one element or key-value pair represents