Algorithms, databases and logic

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

Write your reasoning, then compare it with the indicative marking points. Check your own exam-board specification for required coverage.

5 of 5 questions shown

Loading saved responses

Question 1Hide question4 indicative marks

A sorted list contains 1024 distinct items. Explain binary search and give the worst-case number of midpoint comparisons to find an item or establish it is absent.

Cambridge 2027: Partial conceptual match

Binary-search precondition and logarithmic comparison count are evidenced; this explanation does not implement either search or establish all time/space comparisons.

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

Show indicative guidance

Worked guidance

  1. Each midpoint comparison roughly halves the remaining search interval, including the possibility of a final single item.
  2. Compare the target with the middle item.
  3. Discard the half that cannot contain it, repeating until found or the interval is empty.
  4. Worst case is 11 midpoint comparisons for 1024 items.
  5. The time complexity is O(log n); the list must be sorted.

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

1024 = 2102^{10} does not imply a worst case of ten midpoint comparisons: the final item can require an eleventh.

Question 2A table Enrolment(StudentID, StudentName, CourseID, CourseName) uses (StudentID, CourseID) as its key. StudentID determines StudentName and CourseID determines CourseName. Explain the normalisation problem and propose a decomposition into second normal form.4 indicative marks

A table Enrolment(StudentID, StudentName, CourseID, CourseName) uses (StudentID, CourseID) as its key. StudentID determines StudentName and CourseID determines CourseName. Explain the normalisation problem and propose a decomposition into second normal form.

Cambridge 2027: Partial conceptual match

The supplied dependencies support a 2NF decomposition only; no 3NF judgement or complete normalisation sequence is elicited.

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

Show indicative guidance

Worked guidance

  1. Identify dependencies on only part of the composite key. Separate the entities while preserving their many-to-many enrolment relationship.
  2. The non-key attributes depend on only part of the composite key: partial dependencies.
  3. Create Student(StudentID, StudentName) and Course(CourseID, CourseName).
  4. Keep Enrolment(StudentID, CourseID), using foreign keys to the two new tables.
  5. This avoids repeating student and course names across enrolment rows.

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

Second normal form assumes first normal form; removing partial dependencies is the key step here.

Question 3Simplify NOT(A AND B) using De Morgan's law. Evaluate the result when A = true and B = false.3 indicative marks

Simplify NOT(A AND B) using De Morgan's law. Evaluate the result when A = true and B = false.

Cambridge 2027: Direct conceptual match

Direct De Morgan transformation and Boolean evaluation; mapped to that law, not to all circuits or Karnaugh maps.

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

Show indicative guidance

Worked guidance

  1. Negating a conjunction changes AND to OR and negates each input. Substitute the truth values only after rewriting.
  2. NOT(A AND B) = (NOT A) OR (NOT B).
  3. NOT A is false and NOT B is true.
  4. false OR true is true.

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

Changing only AND to OR without negating both operands is not De Morgan's law.

Question 4A diagnostic light must be on when exactly one of switches A and B is TRUE. Construct the Boolean expression using AND, OR and NOT, write an assignment to Light, and trace inputs (FALSE,FALSE), (FALSE,TRUE), (TRUE,FALSE), (TRUE,TRUE). Explain why A OR B alone fails.4 indicative marks

A diagnostic light must be on when exactly one of switches A and B is TRUE. Construct the Boolean expression using AND, OR and NOT, write an assignment to Light, and trace inputs (FALSE,FALSE), (FALSE,TRUE), (TRUE,FALSE), (TRUE,TRUE). Explain why A OR B alone fails.

Cambridge 2027: Direct conceptual match

Enumerated all four pairs independently; exclusive truth set is 01/10 and distinguishes OR at 11.

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

Show indicative guidance

Worked guidance

  1. Light <- (A AND NOT B) OR (NOT A AND B)
  2. The first term admits A alone; the second admits B alone. For 00 neither term is true, and for 11 both terms are false.
  3. For 01 and 10 exactly one term is true. The four outputs are FALSE, TRUE, TRUE, FALSE; a plain OR would incorrectly output TRUE for 11.

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

Test the both-TRUE case as well as single active inputs.

Question 5Result has non-null rows (ID,Mark,Present): (1,70,TRUE),(2,85,FALSE),(3,90,TRUE),(4,69,TRUE). Write SQL returning the count of rows with Mark>=70 AND Present=TRUE. State the result and explain the effect of replacing AND with OR on these rows.4 indicative marks

Result has non-null rows (ID,Mark,Present): (1,70,TRUE),(2,85,FALSE),(3,90,TRUE),(4,69,TRUE). Write SQL returning the count of rows with Mark>=70 AND Present=TRUE. State the result and explain the effect of replacing AND with OR on these rows.

Cambridge 2027: Direct conceptual match

Checked AND IDs1/3 versus OR IDs1/2/3/4; SQL aggregate is within existing 8.3 DML alignment.

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

Show indicative guidance

Worked guidance

  1. SELECT COUNT(*) FROM Result
    WHERE Mark >= 70 AND Present = TRUE;
  2. Rows 1 and 3 satisfy both requirements. Row 2 fails attendance and row 4 fails the mark threshold, so the count is 2.
  3. With OR, row 2 qualifies on mark and row 4 on attendance; all four then qualify. COUNT(*) counts selected rows, not the sum of marks.

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

Evaluate each row against the whole predicate before counting.

All AS & A Level subjects