Construct algorithms using the access methods of a collection.


Teaching Note:

LINK Connecting computational thinking and program design.


Sample Question:


JSR Notes:

Here we could use the example of a (static) array (like the [] type in Java), but the assessment statement is more likely focusing on the Collection class of Java and its dynamic implementations.

So we could use the Java Collection implementation ArrayList. ArrayList is an "abstract" class which basically acts like an array, except that it can grow and shrink dynamically. It has the following commonly used methods:

So an algorithm could be as follows:

Or see the bottom of page 7 and the top of page 8 of the JETS document for a LinkedList Collection. (But these are more likely to be used in an OOP Option question.)