# CS Principles 2020-2021

## Unit 5 - Lists, Loops, and Traversals

### Lesson 1: Lists Explore

#### CSTA K-12 Computer Science Standards (2017)

AP - Algorithms & Programming
• 3A-AP-14 - Use lists to simplify solutions, generalizing computational problems instead of repeated use of simple variables.

#### CSP2021

AAP-1 - To find specific solutions to generalizable problems, programmers represent and organize data in multiple ways
AAP-1.C - Represent a list or string using a variable.
• AAP-1.C.1 - A list is an ordered sequence of elements. For example, [value1, value2, value3, …] describes a list where value1 is the first element, value 2 is the second element, value 3 is the third element, and so on.
• AAP-1.C.2 - An element is an individual value in a list that is assigned a unique index.
• AAP-1.C.3 - An index is a common method for referencing the elements in a list or string using natural numbers.
AAP-2 - The way statements are sequenced and combined in a program determines the computed result
AAP-2.N - For list operations: a. Write expressions that use list indexing and list procedures. b. Evaluate expressions that use list indexing and list procedures.
• AAP-2.N.2 - List procedures are implemented in accordance with the syntax rules of the programming language.
AAP-2.O - For algorithms involving elements of a list: a. Represent using iterative statements to traverse a list. b. Determine the result of an algorithm with list traversals.
• AAP-2.O.3 - The exam reference sheet providesFOR EACH item IN aList{ <block of statements>}The variable item is assigned the value of each element of aList sequentially, in order, from the first element to the last element. The code in block of statements is exe
• AAP-2.O.4 - Knowledge of existing algorithms that use iteration can help in constructing new algorithms. Some examples of existing algorithms that are often used with lists include:●       determining a minimum or maximum value in a list●       computing a sum or a

### Lesson 2: Lists Investigate

#### CSTA K-12 Computer Science Standards (2017)

AP - Algorithms & Programming
• 3A-AP-14 - Use lists to simplify solutions, generalizing computational problems instead of repeated use of simple variables.
• 3B-AP-23 - Evaluate key qualities of a program through a process such as a code review.

#### CSP2021

AAP-1 - To find specific solutions to generalizable problems, programmers represent and organize data in multiple ways
AAP-1.A - Represent a value with a variable.
• AAP-1.A.3 - Some programming languages provide types to represent data, which are referenced using variables. These types include numbers, Booleans, lists, and strings.
• AAP-1.A.4 - Some values are better suited to representation using one type of data rather than another.
AAP-1.D - For data abstraction: a. Develop data abstraction using lists to store multiple elements. b. Explain how the use of data abstraction manages complexity in program code.
• AAP-1.D.1 - Data abstraction provides a separation between the abstract properties of a data type and the concrete details of its representation.
• AAP-1.D.2 - Data abstractions manage complexity in programs by giving a collection of data a name without referencing the specific details of the representation.
• AAP-1.D.3 - Data abstractions can be created using lists.
• AAP-1.D.4 - Developing a data abstraction to implement in a program can result in a program that is easier to develop and maintain.
• AAP-1.D.5 - Data abstractions often contain different types of elements.
• AAP-1.D.6 - The use of lists allows multiple related items to be treated as a single value. Lists are referred to by different names, such as array, depending on the programming language. EXCLUSION STATEMENT(EK APP-1.D.6): The use of linked lists is outside the scope

### Lesson 3: Lists Practice

#### CSTA K-12 Computer Science Standards (2017)

AP - Algorithms & Programming
• 3A-AP-14 - Use lists to simplify solutions, generalizing computational problems instead of repeated use of simple variables.

#### CSP2021

AAP-1 - To find specific solutions to generalizable problems, programmers represent and organize data in multiple ways
AAP-1.D - For data abstraction: a. Develop data abstraction using lists to store multiple elements. b. Explain how the use of data abstraction manages complexity in program code.
• AAP-1.D.7 - The exam reference sheet provides the notation [value1, value2, value3…] to create a list with those values as the first, second, third, and so on items. For example, ●       aList ← [value1, value2, value3,...] creates a new list that contains the value
• AAP-1.D.8 - The exam reference sheet describes a list structure whose index values are 1 through the number of elements in the list, inclusive. For all list operations, if a list index is less than 1 or greater than the length of the list, an error message is produce
AAP-2 - The way statements are sequenced and combined in a program determines the computed result
AAP-2.D - Evaluate expressions that manipulate strings.
• AAP-2.D.2 - A substring is part of an existing string.
AAP-2.N - For list operations: a. Write expressions that use list indexing and list procedures. b. Evaluate expressions that use list indexing and list procedures.
• AAP-2.N.1 - The exam reference sheet provides basic operations on lists, including: ●       accessing an element by index o   aList[i] accesses the element of aList at index i. The first element of aList is at index 1 and accessed using the notation aList[1
• AAP-2.N.2 - List procedures are implemented in accordance with the syntax rules of the programming language.
AAP-2.O - For algorithms involving elements of a list: a. Represent using iterative statements to traverse a list. b. Determine the result of an algorithm with list traversals.
• AAP-2.O.3 - The exam reference sheet providesFOR EACH item IN aList{ <block of statements>}The variable item is assigned the value of each element of aList sequentially, in order, from the first element to the last element. The code in block of statements is exe

### Lesson 4: Lists Make

#### CSTA K-12 Computer Science Standards (2017)

AP - Algorithms & Programming
• 3A-AP-14 - Use lists to simplify solutions, generalizing computational problems instead of repeated use of simple variables.

### Lesson 5: Loops Explore

#### CSTA K-12 Computer Science Standards (2017)

AP - Algorithms & Programming
• 3A-AP-15 - Justify the selection of specific control structures when tradeoffs involve implementation, readability, and program performance and explain the benefits and drawbacks of choices made.

#### CSP2021

AAP-2 - The way statements are sequenced and combined in a program determines the computed result
AAP-2.K - For iteration: a. Represent using iteration statements. b. Determine the result or side-effect of iteration statements.
• AAP-2.K.1 - Iteration statements change the sequential flow of control by repeating a set of statements zero or more times, until a stopping condition is met.
• AAP-2.K.4 - In REPEAT UNTIL(condition) iteration, an infinite loop occurs when the ending condition will never evaluate to true.

### Lesson 6: Loops Investigate

#### CSTA K-12 Computer Science Standards (2017)

AP - Algorithms & Programming
• 3A-AP-15 - Justify the selection of specific control structures when tradeoffs involve implementation, readability, and program performance and explain the benefits and drawbacks of choices made.
• 3B-AP-23 - Evaluate key qualities of a program through a process such as a code review.
DA - Data & Analysis
• 3A-DA-12 - Create computational models that represent the relationships among different elements of data collected from a phenomenon or process.

#### CSP2021

AAP-3 - Programmers break down problems into smaller and more manageable pieces
AAP-3.F - For simulations: a. Explain how computers can be used to represent real-world phenomena or outcomes. b. Compare the use of simulations with real-world contexts.
• AAP-3.F.1 - Simulations are abstractions of more complex objects or phenomena for a specific purpose.
• AAP-3.F.2 - A simulation is a representation that uses varying sets of values to reflect the changing state of a phenomenon.
• AAP-3.F.3 - Simulations often mimic real-world events with the purpose of drawing inferences, allowing investigation of a phenomenon without the constraints of the real world.
• AAP-3.F.4 - The process of developing an abstract simulation involves removing specific details or simplifying functionality.
• AAP-3.F.5 - Simulations can contain bias derived from the choices of real-world elements that were included or excluded.
• AAP-3.F.6 - Simulations are most useful when real-world events are impractical for experiments (e.g., too big, too small, too fast, too slow, too expensive, or too dangerous).
• AAP-3.F.7 - Simulations facilitate the formulation and refinement of hypotheses related to the objects or phenomena under consideration.
• AAP-3.F.8 - Random number generators can be used to simulate the variability that exists in the real world.

### Lesson 7: Loops Practice

#### CSTA K-12 Computer Science Standards (2017)

AP - Algorithms & Programming
• 3A-AP-15 - Justify the selection of specific control structures when tradeoffs involve implementation, readability, and program performance and explain the benefits and drawbacks of choices made.
DA - Data & Analysis
• 3A-DA-12 - Create computational models that represent the relationships among different elements of data collected from a phenomenon or process.

#### CSP2021

AAP-2 - The way statements are sequenced and combined in a program determines the computed result
AAP-2.K - For iteration: a. Represent using iteration statements. b. Determine the result or side-effect of iteration statements.
• AAP-2.K.2 - The exam reference sheet providesREPEAT n TIMES{ <block of statements>}in which the block of statements is executed n times.
• AAP-2.K.3 - The exam reference sheet providesREPEAT UNTIL(condition){ <block of statements>}in which the code in block of statements is repeated until the Boolean expression condition evaluates to true.
• AAP-2.K.4 - In REPEAT UNTIL(condition) iteration, an infinite loop occurs when the ending condition will never evaluate to true.
• AAP-2.K.5 - In REPEAT UNTIL(condition) iteration, if the conditional evaluates to true initially, the loop body is not executed at all, due to the condition being checked before the loop.
AAP-2.L - Compare multiple algorithms to determine if they yield the same side effect or result.
• AAP-2.L.1 - Algorithms can be written in different ways and still accomplish the same tasks.
• AAP-2.L.2 - Algorithms that appear similar can yield different side effects or results.
• AAP-2.L.5 - Different algorithms can be developed or used to solve the same problem.
CRD-2 - Developers create and innovate using an iterative design process
CRD-2.I - For errors in an algorithm or program: a. Identify the error. b. Correct the error.
• CRD-2.I.3 - A run-time error is a mistake in the program that occurs during the execution of a program. Programming languages define their own run-time errors.
• CRD-2.I.4 - An overflow error is an error that occurs when a computer attempts to handle a number that is outside of the defined range of values.

### Lesson 8: Loops Make

#### CSTA K-12 Computer Science Standards (2017)

AP - Algorithms & Programming
• 3A-AP-15 - Justify the selection of specific control structures when tradeoffs involve implementation, readability, and program performance and explain the benefits and drawbacks of choices made.

### Lesson 9: Traversals Explore

#### CSTA K-12 Computer Science Standards (2017)

AP - Algorithms & Programming
• 3A-AP-14 - Use lists to simplify solutions, generalizing computational problems instead of repeated use of simple variables.
• 3B-AP-10 - Use and adapt classic algorithms to solve computational problems.

#### CSP2021

AAP-2 - The way statements are sequenced and combined in a program determines the computed result
AAP-2.O - For algorithms involving elements of a list: a. Represent using iterative statements to traverse a list. b. Determine the result of an algorithm with list traversals.
• AAP-2.O.1 - Traversing a list can be a complete traversal, where all elements in the list are accessed, or a partial traversal, where only a portion of elements are accessed. EXCLUSION STATEMENT (EK AAP-2.O.1): Traversing multiple lists at the same time using the sam
• AAP-2.O.2 - Iteration statements can be used to traverse a list.
• AAP-2.O.4 - Knowledge of existing algorithms that use iteration can help in constructing new algorithms. Some examples of existing algorithms that are often used with lists include:●       determining a minimum or maximum value in a list●       computing a sum or a
DAT-2 - Programs can be used to process data
DAT-2.D - Extract information from data using a program.
• DAT-2.D.6 - Some processes that can be used to extract or modify information from data include the following:●       transforming every element of a data set, such as doubling every element in a list, or extracting the parent’s email from every student record●

### Lesson 10: Traversals Investigate

#### CSTA K-12 Computer Science Standards (2017)

AP - Algorithms & Programming
• 3A-AP-14 - Use lists to simplify solutions, generalizing computational problems instead of repeated use of simple variables.
• 3B-AP-10 - Use and adapt classic algorithms to solve computational problems.
• 3B-AP-23 - Evaluate key qualities of a program through a process such as a code review.

#### CSP2021

AAP-3 - Programmers break down problems into smaller and more manageable pieces
AAP-3.F - For simulations: a. Explain how computers can be used to represent real-world phenomena or outcomes. b. Compare the use of simulations with real-world contexts.
• AAP-3.F.1 - Simulations are abstractions of more complex objects or phenomena for a specific purpose.
• AAP-3.F.2 - A simulation is a representation that uses varying sets of values to reflect the changing state of a phenomenon.
• AAP-3.F.3 - Simulations often mimic real-world events with the purpose of drawing inferences, allowing investigation of a phenomenon without the constraints of the real world.
• AAP-3.F.4 - The process of developing an abstract simulation involves removing specific details or simplifying functionality.
• AAP-3.F.5 - Simulations can contain bias derived from the choices of real-world elements that were included or excluded.
• AAP-3.F.6 - Simulations are most useful when real-world events are impractical for experiments (e.g., too big, too small, too fast, too slow, too expensive, or too dangerous).
• AAP-3.F.7 - Simulations facilitate the formulation and refinement of hypotheses related to the objects or phenomena under consideration.

### Lesson 11: Traversals Practice

#### CSTA K-12 Computer Science Standards (2017)

AP - Algorithms & Programming
• 3A-AP-14 - Use lists to simplify solutions, generalizing computational problems instead of repeated use of simple variables.
• 3B-AP-10 - Use and adapt classic algorithms to solve computational problems.

#### CSP2021

AAP-2 - The way statements are sequenced and combined in a program determines the computed result
AAP-2.O - For algorithms involving elements of a list: a. Represent using iterative statements to traverse a list. b. Determine the result of an algorithm with list traversals.
• AAP-2.O.3 - The exam reference sheet providesFOR EACH item IN aList{ <block of statements>}The variable item is assigned the value of each element of aList sequentially, in order, from the first element to the last element. The code in block of statements is exe

### Lesson 12: Traversals Make

#### CSTA K-12 Computer Science Standards (2017)

AP - Algorithms & Programming
• 3A-AP-14 - Use lists to simplify solutions, generalizing computational problems instead of repeated use of simple variables.
• 3B-AP-10 - Use and adapt classic algorithms to solve computational problems.

### Lesson 13: Project - Hackathon Part 1

#### CSTA K-12 Computer Science Standards (2017)

AP - Algorithms & Programming
• 3A-AP-14 - Use lists to simplify solutions, generalizing computational problems instead of repeated use of simple variables.
• 3A-AP-16 - Design and iteratively develop computational artifacts for practical intent, personal expression, or to address a societal issue by using events to initiate instructions.
• 3A-AP-22 - Design and develop computational artifacts working in team roles using collaborative tools.
• 3A-AP-23 - Document design decisions using text, graphics, presentations, and/or demonstrations in the development of complex programs.

### Lesson 14: Project - Hackathon Part 2

#### CSTA K-12 Computer Science Standards (2017)

AP - Algorithms & Programming
• 3A-AP-14 - Use lists to simplify solutions, generalizing computational problems instead of repeated use of simple variables.
• 3A-AP-22 - Design and develop computational artifacts working in team roles using collaborative tools.
• 3A-AP-23 - Document design decisions using text, graphics, presentations, and/or demonstrations in the development of complex programs.

### Lesson 15: Project - Hackathon Part 3

#### CSTA K-12 Computer Science Standards (2017)

AP - Algorithms & Programming
• 3A-AP-14 - Use lists to simplify solutions, generalizing computational problems instead of repeated use of simple variables.
• 3A-AP-16 - Design and iteratively develop computational artifacts for practical intent, personal expression, or to address a societal issue by using events to initiate instructions.
• 3A-AP-22 - Design and develop computational artifacts working in team roles using collaborative tools.
• 3A-AP-23 - Document design decisions using text, graphics, presentations, and/or demonstrations in the development of complex programs.

### Lesson 16: Project - Hackathon Part 4

#### CSTA K-12 Computer Science Standards (2017)

AP - Algorithms & Programming
• 3A-AP-14 - Use lists to simplify solutions, generalizing computational problems instead of repeated use of simple variables.
• 3A-AP-16 - Design and iteratively develop computational artifacts for practical intent, personal expression, or to address a societal issue by using events to initiate instructions.
• 3A-AP-22 - Design and develop computational artifacts working in team roles using collaborative tools.
• 3A-AP-23 - Document design decisions using text, graphics, presentations, and/or demonstrations in the development of complex programs.

### Lesson 17: Project - Hackathon Part 5

#### CSTA K-12 Computer Science Standards (2017)

AP - Algorithms & Programming
• 3A-AP-14 - Use lists to simplify solutions, generalizing computational problems instead of repeated use of simple variables.
• 3A-AP-16 - Design and iteratively develop computational artifacts for practical intent, personal expression, or to address a societal issue by using events to initiate instructions.
• 3A-AP-22 - Design and develop computational artifacts working in team roles using collaborative tools.
• 3A-AP-23 - Document design decisions using text, graphics, presentations, and/or demonstrations in the development of complex programs.

#### CSP2021

CRD-2 - Developers create and innovate using an iterative design process
CRD-2.B - Explain how a program or code segment functions.
• CRD-2.B.2 - A code segment refers to a collection of program statements that are part of a program.