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.
41 exam-style questions on OCR GCSE Computer Science Designing, creating and refining algorithms. Each one has a worked solution and a mark scheme showing where the marks go.