Implement and apply an algorithm.
Determine the result of code segments
Learning Objective:
For list operations:
a. Write expressions that use list indexing and list
procedures.
b. Evaluate expressions that the list indexing and list procedures
The exam reference sheet provides basic
operations on lists, including:
accessing an element by index
Text:
aList[i]
Block:
aList i
accesses the element of aList at index i.
The first element of aList is at index 1 and
is accessed using the notation aList[1].
assigning a value of an element of a list to a
variable
Text:
x aList [i]
Learning Objective:
For algorithms involving elements of a list:
a. Write iteration statements to traverse a list
b. Determine the result of an algorithm that includes traversals
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.
Iteration statements can be used to traverse
a list.
AAP-2.O.3
The exam reference sheet provides
Text:
FOR 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
executed once for each assignment of item.
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 average of a list of
numbers
AAP-2.O.5
Linear search or sequential search algorithms
check each element of a list, in order, until the
desired value is found or all elements in the list
have been checked.