Programming and computer systems

Start questions

Unofficial selected-topic practice.

Practice scope

Original English practice with worked guidance. Selected topics only. This is not a complete syllabus, official past-paper collection or predicted exam score. Check your own exam-board specification: these concepts are not certified against a particular board or exam year. Where a question shows a Cambridge 2027 reference, that is a conceptual placement only; no other exam board (such as Edexcel, AQA or OCR) is mapped, so do not assume this covers your board. Content here is written and checked with AI assistance; it has not been approved by an independent teacher or endorsed by any exam board.

160 original questions across 22 selected topic areas. No account or payment required to practise.

Cambridge International AS & A Level Computer Science (9618), examination year 2027: Conceptual alignment to official sources, not exam-board certification. Syllabus mapping and remaining coverage.

5 questions in this topic

Original questions with indicative worked guidance. Selected topics only.

All topics

Original application practice with worked explanations and indicative self-marking points. Not an official exam paper or a board-specific assessment.

5 of 5 questions shown

Loading saved responses

Question 1Hide question3 indicative marks

Trace this pseudocode (TO is inclusive): total <- 0; FOR i <- 1 TO 4; total <- total + i*i; NEXT i; OUTPUT total. OUTPUT executes once, after the loop. State the output and the time complexity when the upper limit is a positive integer n, assuming constant-time arithmetic.

Cambridge 2027: Partial conceptual match

Inclusive loop tracing and linear time are relevant; it neither constructs the requested family of control structures nor compares full algorithms.

Conceptual placement only, not official Cambridge endorsement or complete syllabus coverage.

Show indicative guidance

Worked guidance

  1. The assignment replaces total with its old value plus the current square.
  2. Include i = 4: 121^{2} + 222^{2} + 323^{2} + 424^{2} = 30.
  3. The loop grows linearly with n even though the numerical sum grows faster; output size is not iteration count.

Self-marking points

Tick what your working earned. The count is your own self-assessment.

Self-assessed: not counted yet. This question is worth 3 marks.

Examiner tip

Do not confuse the square in the arithmetic with quadratic algorithmic complexity.

Question 2Define f(n): IF n = 0 RETURN 1; ELSE RETURN n*f(n - 1). For integer n >= 0, find f(4), explain the base case and state the extra stack-space complexity.4 indicative marks

Define f(n): IF n = 0 RETURN 1; ELSE RETURN n*f(n - 1). For integer n >= 0, find f(4), explain the base case and state the extra stack-space complexity.

Cambridge 2027: Direct conceptual match

Factorial call expansion, reachable base case and pending stack frames directly evidence recursion/unwinding concepts; not practical construction certification.

Conceptual placement only, not official Cambridge endorsement or complete syllabus coverage.

Show indicative guidance

Worked guidance

  1. Expand the recursive calls until f(0), then return upward through the pending multiplications.
  2. Returning 0 at the base case would multiply the entire result by zero; 1 is the multiplicative identity.
  3. Each unfinished multiplication keeps a stack frame alive. This is not tail recursion because work remains after the recursive call.

Self-marking points

Tick what your working earned. The count is your own self-assessment.

Self-assessed: not counted yet. This question is worth 4 marks.

Examiner tip

A base case must be reachable. Inputs outside the specified nonnegative integer domain need validation.

Question 3A tutoring app has one remaining seat. Two users both read seats = 1, then each confirms a booking and writes seats = 0. Explain the fault and propose a database-level solution that prevents overbooking.4 indicative marks

A tutoring app has one remaining seat. Two users both read seats = 1, then each confirms a booking and writes seats = 0. Explain the fault and propose a database-level solution that prevents overbooking.

Cambridge 2027: Board-neutral enrichment

SQL row locking, transactional seat booking and atomic conditional decrements are not explicit requirements of the listed DBMS/SQL content. Do not force onto generic process management.

Conceptual placement only, not official Cambridge endorsement or complete syllabus coverage.

Show indicative guidance

Worked guidance

  1. The two reads happen before either write, so both users believe the seat is available. Merely refreshing the UI cannot guarantee correctness.
  2. An atomic operation makes checking and changing availability indivisible. Exactly one update can change 1 to 0.
  3. Keep the successful decrement and booking insert in one transaction so an insert failure cannot consume the seat without a booking.

Self-marking points

Tick what your working earned. The count is your own self-assessment.

Self-assessed: not counted yet. This question is worth 4 marks.

Examiner tip

A transaction alone is not enough unless its locking, isolation or conditional-update behaviour actually prevents the race.

Question 4Trace PROCEDURE Adjust(BYVAL X:INTEGER, BYREF Y:INTEGER): X<-X+2; Y<-Y+X; ENDPROCEDURE. The caller sets A<-3; B<-4 and calls Adjust(A,B). Give local X, final A and B, and explain why changing BYVAL X to BYREF changes A. Treat X and Y as distinct arguments.4 indicative marks

Trace PROCEDURE Adjust(BYVAL X:INTEGER, BYREF Y:INTEGER): X<-X+2; Y<-Y+X; ENDPROCEDURE. The caller sets A<-3; B<-4 and calls Adjust(A,B). Give local X, final A and B, and explain why changing BYVAL X to BYREF changes A. Treat X and Y as distinct arguments.

Cambridge 2027: Direct conceptual match

Simulated copy/reference cells: local5, caller3/9; reference/reference variant5/9 with no aliasing.

Conceptual placement only, not official Cambridge endorsement or complete syllabus coverage.

Show indicative guidance

Worked guidance

  1. Initially the local copy X is 3 and Y refers to B=4. Increasing X gives 5 without writing to A.
  2. The update through Y adds that local 5 to 4, so B becomes 9; A stays 3.
  3. Passing X by reference instead links X to A. The same assignments then leave A=5 and B=9; distinct arguments avoid an aliasing ambiguity.

Self-marking points

Tick what your working earned. The count is your own self-assessment.

Self-assessed: not counted yet. This question is worth 4 marks.

Examiner tip

Separate the value held in a local parameter from the caller's storage.

Question 5For nonnegative integer N, trace I<-1; Total<-0; WHILE I<N: Total<-Total+I; I<-I+1; ENDWHILE; OUTPUT Total. Give outputs for N=0,1,4. The requirement is to sum integers 1 through N inclusive. Correct the condition and give the three corrected outputs; explain why a pre-condition loop handles N=0.4 indicative marks

For nonnegative integer N, trace I<-1; Total<-0; WHILE I<N: Total<-Total+I; I<-I+1; ENDWHILE; OUTPUT Total. Give outputs for N=0,1,4. The requirement is to sum integers 1 through N inclusive. Correct the condition and give the three corrected outputs; explain why a pre-condition loop handles N=0.

Cambridge 2027: Direct conceptual match

Ran original/corrected loops at0/1/4; boundary test exposes omitted upper endpoint.

Conceptual placement only, not official Cambridge endorsement or complete syllabus coverage.

Show indicative guidance

Worked guidance

  1. At N=4 the original loop adds 1,2,3 and stops before 4, giving 6; at N=0 or 1 it never enters and returns 0.
  2. I <- 1
    Total <- 0
    WHILE I <= N
       Total <- Total + I
       I <- I + 1
    ENDWHILE
    OUTPUT Total
  3. The corrected N=0,1,4 cases yield 0,1,10. For N=0 the initial condition is false, avoiding an unwanted addition that a compulsory first iteration could make.

Self-marking points

Tick what your working earned. The count is your own self-assessment.

Self-assessed: not counted yet. This question is worth 4 marks.

Examiner tip

Include the zero and one cases, not just a typical multi-iteration input.

All AS & A Level subjects