Lesson 8: Multiple Lists
45 minutes
Overview
How can I implement algorithms involving multiple lists?
Students explore traversing multiple lists at the same time by creating algorithms and tracing code involving multiple lists. Students identify scenarios where multiple lists might be needed and consider how multiple lists might be used and traversed in games. Students then continue working through the tasks on their Project Planning Board to develop their Creative Coding with the Console Project.
Standards
CON-2 - Programmers incorporate iteration and selection into code as a way of providing instructions for the computer to process each of the many possible input values
CON-2.J - For algorithms in the context of a particular specification that requires the use of ArrayList traversals: • Identify standard algorithms. • Modify standard algorithms. • Develop an algorithm.
- CON-2.J.2 - Some algorithms require multiple String, array, or ArrayList objects to be traversed simultaneously.
Agenda
Objectives
Students will be able to:
- Write algorithms to traverse multiple lists at the same time
Preparation
- Check the Teacher's Lounge for verified teachers on the CSA Forum to find additional strategies or resources shared by fellow teachers
Links
Heads Up! Please make a copy of any documents you plan to share with students.
For the students
- U8L8 Extra Practice - Handout
Teaching Guide
Warm Up (10 minutes)
Creating a Playlist
Remarks
Sometimes our programs need to work with multiple lists to find information or to combine multiple lists into one list without any duplicates. These problems require a combination of standard algorithms we have learned throughout the year.
Do This: Click through the animated slide to introduce the scenario.
Group: Place students into pairs.
Do This: Have students brainstorm an algorithm for the scenario. Have students share their algorithms with another group to compare solutions.
Encourage students to consider the standard algorithms they have implemented throughout the year and how these can be applied to this scenario. Ask students to identify which standard algorithms would be applicable to the scenario and what modifications they would need to make to the standard algorithms to solve this problem.
Discuss: Click through the animated slide to display the prompts.
- What is your algorithm?
- What characteristics were common in your algorithms?
Discussion Goal: Students share the algorithms they developed and identify common characteristics, such as creating an ArrayList
to combine the two lists or traversing both lists simultaneously to retrieve the data.
Activity (30 minutes)
Traversing Multiple Lists (15 minutes)
Remarks
Software engineers often need to work with multiple lists in a program. Each list might have different types of data or store information for different users or scenarios. Let's take a look at an example.
Do This: Review the lesson objectives.
Group: Place students in pairs.
Do This: Direct students to Level 1 on Code Studio to predict the program's outcome, then run the program to compare their predictions to the actual outcome.
Discuss: Click through the animated slide to display the prompts.
- What do you notice about the code in this program?
- What do you wonder about the code in this program?
Discussion Goal: Students notice that the program has multiple lists and that there are methods to find information and combine the lists into one list without any duplicate values. Students may wonder about other scenarios where these algorithms might be useful, other scenarios requiring multiple lists, or other problems that could be solved involving multiple lists.
Remarks
Most of the problems software engineers solve involving multiple lists use the same standard algorithms we have implemented with one list. Let's practice using these algorithms to traverse multiple lists.
Do This: Direct students to Level 2 on Code Studio to complete Levels 2 and 3. Students complete a Check for Understanding on Level 2, then continue to complete a choice level on Level 3 to traverse multiple lists.
Encourage students to write pseudocode first, then translate their solution to Java.
Project Development (15 minutes)
Remarks
Using the items on your Project Planning Board, continue to develop your Creative Coding Project. Each time you complete a goal, commit your code and move the tasks to the next column. There should only be one item in the “In Progress” column at a time, meaning that each item should be entirely completed before moving on to the next item.
Do This: Direct students to Level 4 on Code Studio to work on their Creative Coding with the Console Project.
Remind students to refer to their Project Planning Board to decide what tasks to work on during this time. You can also encourage students to request a code review from their peers as they work.
Do This: Have students update their Project Planning Board and Project Backlog with any tasks they completed, changed, or added.
Wrap Up (5 minutes)
Revisiting the Need to Knows
Remarks
We just learned a lot of new information today, which may have even answered some of the Need to Know questions you wrote down about the Creative Coding Project. As we progress through the unit, it is helpful to stop and note what we have learned that is related to or useful for the project.
Do This: Have students review the questions they wrote in the "Need to Know" column on page two of their Creative Coding with the Console Project Planning Guide. Students add new questions to this column, check off any answered questions, and write answers to any questions in the "Learned" column.
Do This: Have students share what they added to their chart with a partner.
If time permits, you can also have students share as a class.
Do This: Review the concepts covered in this lesson.
Assessment: Check for Understanding
Check For Understanding Question(s) and solutions can be found in each lesson on Code Studio. These questions can be used for an exit ticket.
AP Classroom Topic Questions
To assign questions from the AP Classroom Question Bank that align with this lesson, create a custom quiz in AP Classroom by searching the Question Bank for the Essential Knowledge statements listed at the top of this lesson plan. You can find instructions and video demonstrations to do this on AP Central.
This work is available under a Creative Commons License (CC BY-NC-SA 4.0).
If you are interested in licensing Code.org materials for commercial purposes contact us.