Day 20 - Other Collection Types

Day 20: Other Collection Types

Learning Objectives

Essential Questions

Materials Needed

Vocabulary

Procedure (50 minutes)

Opening (8 minutes)

  1. Review and Connection (3 minutes)

    • Review 2D lists and nested loops from previous lesson
    • Connect to today's focus on other ways to organize collections of data
  2. Warm-up Activity (5 minutes)

    • Present a problem that's awkward to solve with lists (e.g., storing student grades by name)
    • Ask students how they might approach this with what they know so far
    • Discuss limitations of lists for certain types of data organization

Main Activities (32 minutes)

  1. Lecture: Other Collection Types (12 minutes)

    • Introduce dictionaries/maps as key-value collections:
      • Structure: mapping keys to values
      • Purpose: fast lookup by key
      • Common uses: name-value associations, property lists
      • Operations: creating, accessing by key, modifying, checking existence
    • Introduce sets as unordered collections of unique elements:
      • Structure: collection with no duplicates
      • Purpose: membership testing, eliminating duplicates
      • Common uses: unique items, set operations
      • Operations: adding, removing, checking membership
    • Compare different collection types:
      • Lists: ordered collections, access by position
      • Dictionaries: key-value pairs, access by key
      • Sets: unique elements, membership testing
    • Discuss when to use each collection type:
      • Lists: when order matters, when duplicates are allowed
      • Dictionaries: when you need to look up values by a key
      • Sets: when you only care about membership, not order or count
    • Explain how these collections provide data abstraction
  2. Demo: Using Different Collection Types (8 minutes)

    • Walk through examples of different collection types:
      • Creating and using dictionaries for name-value associations
      • Using sets for membership testing and duplicate elimination
      • Converting between collection types
    • Demonstrate solving problems with appropriate collections:
      • Student grade tracker using dictionaries
      • Unique visitor tracker using sets
      • Frequency counter using dictionaries
    • Show how to choose the right collection for different scenarios
    • Highlight the advantages of each collection type
  3. Hands-on: Choosing Appropriate Collections for Different Problems (12 minutes)

    • Students work in the programming environment
    • Present several problem scenarios
    • Students determine which collection type is most appropriate for each
    • Have students implement solutions using the chosen collection types
    • Problem ideas:
      • Word frequency counter
      • Contact list manager
      • Inventory system
      • Unique item tracker
    • Encourage students to explain their choice of collection type

Closing (10 minutes)

  1. Activity: Converting Between Collection Types (5 minutes)

    • Provide students with data in one collection format
    • Students convert it to another format to solve a specific problem
    • Examples:
      • Converting a list to a set to find unique elements
      • Converting a list to a dictionary for faster lookup
      • Creating a frequency dictionary from a list
    • Share and discuss different approaches
    • Highlight the strengths of each collection type
  2. Exit Ticket and Preview (5 minutes)

    • Students create a program that uses appropriate collection types
    • Preview that next class will focus on algorithm efficiency

Assessment

Differentiation

For Advanced Students

For Struggling Students

Homework/Extension

Teacher Notes