Designing, creating and refining algorithms
9
0/4

This pseudocode algorithm is intended to calculate and print the total conductance of an electrical circuit, which is the sum of the reciprocals of the individual resistances stored in the 0-indexed array resistances.

01  total_conductance = 0
02  for index = 0 to resistances.length
03      resistances[index] = total_conductance + 1 / resistances[index]
04  next index
05  print(total_conductance)

The function length returns the number of elements in the array.

The algorithm contains several errors.

Identify two logic errors in the pseudocode algorithm.

Write the refined line to correct each error.

[4]

Designing, creating and refining algorithms Questions

Practise OCR GCSE Computer Science Designing, creating and refining algorithms with exam-style questions for GCSE Computer Science. 50 questions, matched to the OCR GCSE Computer Science (J277) specification and written in Component 01 and Component 02 style. Every question includes a full worked solution and mark scheme, so you can see where marks are awarded rather than just whether you got the answer right.

PreviousNext

Designing, creating and refining algorithms Questions

  1. GCSE
  2. /Computer Science
  3. /Designing, creating and refining algorithms