JCE Computer Studies study materials
JCE Computer Studies study resources

JCE Computer Studies: Algorithms, Programming and Problem Solving

JCE Computer Studies · Work through your exam, one topic at a time.

All guide sections

Algorithms, Programming and Problem Solving

An algorithm is a finite sequence of unambiguous steps that solves a problem. The exam tests algorithm design tools, control structures, standard algorithms, and the ability to trace code by hand.

Properties and tools

An algorithm must be finite, definite (no ambiguity), have zero or more inputs, produce output, and be effective. Tools: pseudocode and flowcharts. Flowchart symbols - oval for start/stop, parallelogram for input/output, rectangle for process, diamond for decision, arrows for flow.

Control structures

Sequence, selection (IF…THEN…ELSE, CASE), and iteration. A FOR loop repeats a known number of times; a WHILE loop tests before the body and may run zero times; REPEAT…UNTIL tests after the body, so it always runs at least once.

Standard algorithms

Linear search checks each item in turn, works on unsorted data, and gets slower as the list grows. Binary search requires sorted data and halves the search space each time. Bubble sort repeatedly swaps adjacent out-of-order pairs, needing up to n−1 passes. Selection sort finds the smallest remaining item and swaps it into place.

Errors

Syntax errors stop translation; runtime errors occur while running (division by zero); logic errors let the program run but produce wrong output.

Worked example

Trace pass 1 of a bubble sort on [5, 2, 9, 1]. Compare 5 and 2 → swap → [2, 5, 9, 1]. Compare 5 and 9 → already ordered, no swap. Compare 9 and 1 → swap → [2, 5, 1, 9]. After one pass the largest value, 9, is in its final position. A list of 4 items needs at most 3 passes.

Traps that cost marks

  • Using binary search on unsorted data.
  • Writing = (assignment) where == (comparison) is meant.
  • Running a FOR loop n times when n−1 passes are needed.
  • Not initialising a running total to 0, or a maximum to the first item.
  • Confusing a logic error with a syntax error.