Community resourceWorksheet

1CP2-CT-9.2 One-dimensional structures reverse traversal and efficiency

Part 2 of 4 · 1CP2-CT-9 · Testing, structures and integrated solutions

A one-dimensional list stores an ordered sequence under one name. The first index is 0 and the last is len(values) - 1. Traversing backwards changes visit order; it does not sort or reverse the stored list.

Students will:

  • traverse a one-dimensional structure in reverse order
  • predict changing indexes and output before execution
  • reason about efficiency from the work performed
  • construct a PLS-compatible reverse traversal

Inside: 6 explanation cells, 1 fill-in-the-blanks cell, 2 multiple-choice questions, 3 written answers, 1 trace table and 1 Python task. 14 marks, about 45 minutes.

Series: 1CP2-CT-9 · Testing, structures and integrated solutions, part 2 of 4.

Shared by Coding PathwayVerified teacher

  • 14 cells
  • About 45 minutes
  • CC BY-SA 4.0
  • Shared 17 Aug 2026

Preview

The whole resource, exactly as a class sees it. Answers and marking are held back.

One-dimensional structures, reverse traversal and efficiency

A one-dimensional list stores an ordered sequence under one name. The first index is 0 and the last is len(values) - 1. Traversing backwards changes visit order; it does not sort or reverse the stored list.

1. Choose indices deliberately

Forward and reverse list traversal01234ABCDEforward: 0, 1, 2, 3, 4reverse: 4, 3, 2, 1, 0

The PLS-compatible reverse pattern is for position in range(len(values) - 1, -1, -1):. The start is the last valid index, the stop is -1 because Python excludes it, and the step is -1.

Fill in the blanks3 marks
For a list of length 6, the last index is gap 1. Reverse traversal starts there, uses a step of gap 2 and leaves the list gap 3.
  • -1
  • 1
  • 5
  • unchanged
Multiple choice1 mark

Which sequence is produced by range(4, -1, -1)?

  • A4, 3, 2, 1, 0
  • B4, 3, 2, 1, 0, -1
  • C0, 1, 2, 3, 4
  • D4 only

2. Predict before execution

letters = ["A", "B", "C", "D"]
result = ""
for position in range(len(letters) - 1, -1, -1):
    result = result + letters[position]
print(result)
Multiple choice1 mark

What exact text is printed?

  • AABCD
  • BDCBA
  • C3210
  • DD
Written answer2 marks

Explain why the original letters list is still ["A", "B", "C", "D"] after execution.

Separate reading order from assignment to the list.

Students type their answer here.

Trace table5 marks

Complete the reverse-traversal trace.

Record position, value and total on each pass.

Use one row for each pass through the loop. Fill in a box only when that value changes on that row, and leave the rest blank.

ProgramPython
  1. values = [3, 5, 2]
  2. total = 0
  3. for position in range(len(values) - 1, -1, -1):
  4. total = total + values[position]
  5. print(total)
Trace table with 4 columns
RowvaluestotalpositionOutput
1
2
3
4
5
6
7

3. Use evidence, not absolutes

If a search starts from the newest entry at the end and the target is usually recent, reverse traversal may use fewer comparisons. If targets are usually near the start, forward traversal may be better. Direction alone is not always more efficient; the data distribution and stopping rule matter.

Written answer2 marks

A log stores oldest entries first and recent errors are most likely to be requested. Explain why reverse search may be suitable.

Link likely position to comparisons.

Students type their answer here.

4. Construct reverse traversal

Complete the program so reverse_values contains every item from values in reverse visit order. Use indices; do not use slicing or a built-in reverse method.

Coding task4 marks
values = [4, 7, 1, 9]
reverse_values = []
# Traverse from the last index to 0 and append each item.

print(reverse_values)
Written answer1 mark

State one measure other than comparisons that could be used when evaluating a program's efficiency.

Use a measurable resource.

Students type their answer here.

Route forward

You can traverse in either direction and justify the choice. Next you will combine file text, type conversion, lists and returned values in one decomposed solution.