Maps, Sets, and Records

  1. Looking Up a Key in a Dictionary

    A dictionary connects each distinct key to a value. A lookup needs a policy for a key that has no entry.

    Undergraduate
  2. Counting Frequencies in a Dictionary

    A frequency map associates each observed key with the number of times it occurred.

    Undergraduate
  3. Sets, Membership, and Duplicate Values

    A set stores membership under an equality rule and does not retain a separate entry for every occurrence.

    Undergraduate
  4. Set Union, Intersection, and Difference

    Set operations combine membership questions and can express inclusion, overlap, and exclusion without a separate search for every element.

    Undergraduate
  5. Finding Changed Membership with Symmetric Difference

    Symmetric difference contains items present in exactly one of two sets. It detects membership changes in either direction.

    Undergraduate
  6. Checking Required Membership with Subsets

    A subset test verifies that every required element appears in an available set.

    Undergraduate
  7. Dictionary Insertion Order and Sorting

    Python dictionaries preserve insertion order. This order is useful for source history and can differ from ascending key order.

    Undergraduate
  8. Dictionary Keys, Values, and Items

    A dictionary view can traverse its labels, its stored values, or pairs of both. Pick a view that preserves the evidence a caller needs.

    Undergraduate
  9. Using a Dictionary to Group Records

    A grouping map stores one collection for each key and preserves every received record in the appropriate group.

    Undergraduate
  10. Building a Reverse Index from a Mapping

    A reverse mapping relates values back to their original keys. Repeated values can require multiple keys per reverse entry.

    Undergraduate
  11. Merging Settings at Different Priorities

    Settings often combine default, environment, and user values. Define which supplied entry wins for a shared key.

    Undergraduate
  12. Live Dictionary Views and Snapshots

    A live view observes changes to the same dictionary. A collected sequence of view items fixes the items observed at collection time.

    Undergraduate
  13. Using Composite Keys in a Dictionary

    A composite key joins several fields into one lookup identity. Every field participating in that identity needs a stable representation.

    Undergraduate
  14. A Record with Named Fields

    A record associates names with a defined set of fields describing one object, observation, or result.

    Undergraduate
  15. Optional Fields in a Record

    An omitted field and a present field carrying an empty value can be different states of a record.

    Undergraduate
  16. Joining Two Collections by Key in Memory

    A lookup map can associate items from two collections efficiently when join keys and multiplicities are understood.

    Undergraduate
  17. A Visited Set in a Search

    A visited set remembers explored states so a search can avoid repeatedly expanding the same state.

    Undergraduate
  18. A Dictionary as a Simple Result Cache

    A cache reuses results for equivalent calls. The chosen key has to capture every input that changes the result.

    Undergraduate
  19. Ordered and Unordered Collection Equality

    A list, set, and frequency map answer different equality questions about order and multiplicity.

    Undergraduate
  20. Case Folding for Collection Keys

    Normalize lookup keys when a domain defines a case-insensitive identity. Apply the same rule to both storage and retrieval.

    Undergraduate
  21. A Queue of Work Records

    A work queue can hold an identifier, input values, and enough context for each task to be handled in arrival order.

    Undergraduate
  22. Building an Index Before Looking Up References

    A first pass can index records, and a second can resolve references regardless of where their targets appear in the input.

    Undergraduate
  23. Collection Size and Retained Memory

    Element count is one part of a collection's memory use. The referenced values and spare storage can also matter.

    Undergraduate
  24. Building a Categorical Histogram

    A categorical histogram counts how many records fall under each label and reports the counts under a chosen order.

    Undergraduate
  25. Partitioning Records into Disjoint Groups

    A partition places each input item into exactly one group. A grouping rule can otherwise duplicate a row across overlapping labels.

    Undergraduate
  26. Subtracting Inventories with Counts

    A multiset keeps the number of occurrences of each key. A count-based difference can show unmet quantity even when a key is available.

    Undergraduate
  27. Making an Immutable Snapshot of a Record

    An immutable snapshot preserves selected values at one moment so later mutations elsewhere cannot silently rewrite the observation.

    Undergraduate
  28. Caching a Missing Lookup Result

    Caching a missing result can avoid repeated expensive work, but the application needs a policy for when absence can change.

    Undergraduate
  29. Turning a Mapping into Report Rows

    A report row can retain the key and value from a mapping while presenting them in an independently chosen order.

    Undergraduate
  30. Choosing Stable Identifiers for Stored Records

    An identifier remains attached to an entity when mutable descriptions change. It gives collections a reliable key for updates and links.

    Undergraduate