Computer Science
Algorithms, databases and logic
- 1.
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.
[4 marks] · no calculatorAnswer explanation
Draft walkthroughs are based on marking guidance, not independently verified derivations.
- Each midpoint comparison roughly halves the remaining search interval, including the possibility of a final single item.
- Compare the target with the middle item.
- Discard the half that cannot contain it, repeating until found or the interval is empty.
- Worst case is 11 midpoint comparisons for 1024 items.
- The time complexity is O(log n); the list must be sorted.
Marking points
- Compare the target with the middle item.
- Discard the half that cannot contain it, repeating until found or the interval is empty.
- Worst case is 11 midpoint comparisons for 1024 items.
- The time complexity is O(log n); the list must be sorted.
Examiner tip: 1024 = 2^10 does not imply a worst case of ten midpoint comparisons: the final item can require an eleventh.
- 2.
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.
[4 marks] · no calculatorAnswer explanation
Draft walkthroughs are based on marking guidance, not independently verified derivations.
- Identify dependencies on only part of the composite key. Separate the entities while preserving their many-to-many enrolment relationship.
- The non-key attributes depend on only part of the composite key: partial dependencies.
- Create Student(StudentID, StudentName) and Course(CourseID, CourseName).
- Keep Enrolment(StudentID, CourseID), using foreign keys to the two new tables.
- This avoids repeating student and course names across enrolment rows.
Marking points
- The non-key attributes depend on only part of the composite key: partial dependencies.
- Create Student(StudentID, StudentName) and Course(CourseID, CourseName).
- Keep Enrolment(StudentID, CourseID), using foreign keys to the two new tables.
- This avoids repeating student and course names across enrolment rows.
Examiner tip: Second normal form assumes first normal form; removing partial dependencies is the key step here.
- 3.
Simplify NOT(A AND B) using De Morgan's law. Evaluate the result when A = true and B = false.
[3 marks] · no calculatorAnswer explanation
Draft walkthroughs are based on marking guidance, not independently verified derivations.
- Negating a conjunction changes AND to OR and negates each input. Substitute the truth values only after rewriting.
- NOT(A AND B) = (NOT A) OR (NOT B).
- NOT A is false and NOT B is true.
- false OR true is true.
Marking points
- NOT(A AND B) = (NOT A) OR (NOT B).
- NOT A is false and NOT B is true.
- false OR true is true.
Examiner tip: Changing only AND to OR without negating both operands is not De Morgan's law.
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.