Back to Topic 6.2 — Data structures
6.2.2Computer Science SL5 flashcards

Arrays and lists

Practice Flashcards

Flip to reveal answers
Card 1 of 56.2.2
6.2.2
Question

How are items in a list addressed?

Click to reveal answer

Track your progress — Sign up free to save your progress and get smart review reminders based on spaced repetition.

All 5 Flashcards — Arrays and lists

Sign up free to track progress and get spaced-repetition review schedules.

Card 1concept

Question

How are items in a list addressed?

Answer

By position, starting at 0. A list of four items has positions 0, 1, 2 and 3, so asking for position 4 is an error — the commonest list bug there is.

Card 2definition

Question

How do you add to and remove from a dynamic list?

Answer

append adds at the end, insert(position, value) adds anywhere and shifts the rest along. remove(value) takes out the first match, and pop() removes the last item and gives it back.

Card 3concept

Question

Why must you not remove items while looping over a list?

Answer

Removing shifts everything after it down one place while the loop counter moves up, so items get skipped silently. Build a new list instead, or loop over a copy.

Card 4definition

Question

What is a 2D list and how is it addressed?

Answer

A list whose items are themselves lists — a grid. It is addressed [row][column], always in that order: grid[1][2] is row 1, column 2.

Card 5concept

Question

Why does visiting every cell of a grid need a nested loop?

Answer

The outer loop gives you each row, which is itself a list; the inner loop reaches the individual values inside it. That is also why scanning a grid is O(rows × columns).

Track your progress with spaced repetition

Sign up free — Aimnova tells you exactly which cards to review and when, so you remember everything before your IB exam.

Start Free
IB Computer Science Arrays and lists Flashcards | 6.2.2 | Aimnova