Computer Science
Programming and computer systems
- 1.
Trace this pseudocode: total <- 0; FOR i <- 1 TO 4 inclusive: total <- total + i*i; OUTPUT total. State the output and the time complexity if the upper limit is n.
[3 marks] · no calculator - 2.
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.
[4 marks] · no calculator - 3.
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.
[4 marks] · no calculator
Marking points are indicative, not an official mark scheme. Accept equivalent valid methods and supported interpretations that address the task; award each mark once without requiring the model wording.