Day 16 - Introduction to Lists/Arrays
Day 16: Introduction to Lists/Arrays
Learning Objectives
- AAP-1.C: Represent a list or string using a variable.
- AAP-1.D: For data abstraction: Develop data abstraction using lists to store multiple elements.
- AAP-2.M: For algorithms involving elements of a list: Write iteration statements to traverse a list.
- AAP-2.N: For list operations: Write expressions that use list indexing and list procedures.
Essential Questions
- How do lists allow us to store and manipulate collections of data?
- How do we use lists to represent and solve real-world problems?
Materials Needed
- Presentation slides on lists/arrays
- Programming environment
- List manipulation worksheet
- Sample data sets
- Exit ticket templates
Vocabulary
- List
- Array
- Element
- Index
- Collection
- Data structure
- Sequence
- Traversal
- Data abstraction
Procedure (50 minutes)
Opening (8 minutes)
-
Review and Week 4 Introduction (3 minutes)
- Review modular program design from previous lesson
- Introduce Week 4 focus on data structures and algorithms
- Connect to today's focus on lists as a fundamental data structure
-
Warm-up Activity (5 minutes)
- Present a scenario requiring storage of multiple related values (e.g., student grades)
- Ask students how they might store this data using what they know so far
- Discuss limitations of using individual variables
- Introduce the need for collections of data
Main Activities (32 minutes)
-
Lecture: Lists/Arrays as Data Structures (12 minutes)
- Define lists as ordered sequences of elements
- Explain the concept of data abstraction using lists
- Discuss list terminology:
- Element: individual value in a list
- Index: position of an element in a list
- Length: number of elements in a list
- Explain list representation in pseudocode:
- Creating lists: aList ← [value1, value2, value3, ...]
- Empty lists: aList ← []
- Discuss list indexing (starting at 1 in AP CSP pseudocode)
- Explain basic list operations:
- Accessing elements: aList[i]
- Assigning values: aList[i] ← x
- Getting list length: LENGTH(aList)
- Discuss how lists provide data abstraction:
- Treating multiple values as a single unit
- Hiding implementation details
- Representing complex data structures
-
Demo: Creating and Accessing List Elements (8 minutes)
- Walk through examples of creating and using lists:
- Creating lists with different data types
- Accessing elements by index
- Modifying list elements
- Working with list lengths
- Demonstrate common list patterns:
- Initializing lists
- Accessing first and last elements
- Updating elements
- Working with lists of different data types
- Show how lists can represent real-world collections
- Highlight common errors with list indexing
- Walk through examples of creating and using lists:
-
Hands-on: Manipulating Lists in Code (12 minutes)
- Students work in the programming environment
- Guide students through creating and manipulating lists
- Have students implement programs that:
- Create lists of different types (numbers, strings, etc.)
- Access and modify list elements
- Perform calculations with list elements
- Solve problems using lists (finding max/min, calculating averages, etc.)
- Encourage students to experiment with different list operations
Closing (10 minutes)
-
Activity: Solving Problems Using Lists (5 minutes)
- Present students with problems that can be solved using lists
- Students design and implement solutions
- Share and discuss different approaches
- Highlight how lists simplify working with collections of data
-
Exit Ticket and Preview (5 minutes)
- Students complete exercises involving list creation and manipulation
- Preview that next class will focus on list operations and algorithms
Assessment
- Formative: Quality of list manipulation during hands-on activities
- Exit Ticket: Correctness of list creation and manipulation exercises
Differentiation
For Advanced Students
- Challenge them with more complex list manipulations
- Introduce the concept of nested lists (preview)
- Have them implement more sophisticated list-based solutions
For Struggling Students
- Provide more structured guidance on list operations
- Focus on basic list creation and access before moving to complex operations
- Use visual aids to illustrate list indexing
Homework/Extension
- Complete a worksheet with list manipulation exercises
- Create a program that uses lists to solve a real-world problem
- Research how lists/arrays are implemented in different programming languages
Teacher Notes
- Emphasize that lists are one of the most fundamental data structures in programming
- Watch for confusion about list indexing (especially if students have experience with 0-indexed languages)
- Make connections to real-world collections of data
- Consider using physical objects to demonstrate list concepts
- Remind students that understanding lists is essential for many algorithms