Bangor University exam paper (bangorexam)
Cameron Gray's bangorexam class (1.6.0), used by Bangor University's computer science department since 2016/17 for its examination papers: bilingual English/Welsh cover with school, module, exam period, time allowed and calculator/notes rules; compulsory Section A and n-from Section B (or single-section papers), marks, multiple-choice questions and an examiner's copy with solutions via the answers option.
- Category
- Teaching
- Document class
bangorexam(bangorexam.cls) — ships with TeX Live- Workflow
- Assignment / problem set — no revision rounds
- Author
- Cameron Gray (bangorexam)
- Source
- Cameron Gray (bangorexam)
- Licence
- bangorexam.cls: LaTeX Project Public License (installed with TeX). The sample text is Cameron Gray (bangorexam)'s, provided for authors preparing a submission.
These are the publisher’s own files. This project starts from Cameron Gray (bangorexam)’s package for this publication — their manuscript, their bangorexam.cls, their bibliography style — so what compiles here is what they would have given you.
Cameron Gray (bangorexam) serves this exact file to Bangor University. Check Cameron Gray (bangorexam)’s author pages for the current instructions.
Where this differs from the publisher’s download.
- Added: exam.tex: a short Section A/B paper written from the macros and environments documented in bangorexam.dtx (\school, \module, \examperiod, \timeallowed, \nfrom, \calculatorsallowed, \guidance, \sectiona, \sectionb, questions, parts, solution, choices with \correctchoice); the CTAN package has no sample file — Cameron Gray (bangorexam)’s package references this without including it, so the project would not have built as downloaded.
- Changed: exam.tex: \usepackage{amsmath,amssymb} removed (the class loads newpxtext/newpxmath, whose symbols clash with amssymb's \Bbbk), and \calculatorallowed corrected to the class's \calculatorsallowed (2026-11-23)..
- Note: Written for Bangor University's Computer Science exams by a member of staff; other schools should check their own exam-paper rules. Add the answers class option for the examiner's copy.
What you get
exam.tex— the file that is compiled · 2 KB
These become your files. Editing them afterwards changes your project and nothing else — a project owns its files from the moment it is made.
Link to this template. Send it to a student or co-author: it starts a new paper in this template, through sign-up if they need an account.
https://manulyx.com/start/ctan-bangorexam
Source
exam.tex — the file that is compiled · 2 KB
% Sample examination paper for the bangorexam class (in TeX Live).
% Written from the macros and environments documented in bangorexam.dtx (version of 2025-10-04).
% Class options: ab (Section A compulsory, Section B n-from), aonly, nfrom;
% add "answers" for the examiner's copy with solutions, e.g. \documentclass[ab,answers]{bangorexam}.
\documentclass[ab]{bangorexam}
% The class loads newpxtext/newpxmath, which provide amsmath and the AMS symbols.
\school{School of Computer Science and Engineering}{Ysgol Cyfrifiadureg a Pheirianneg}
\module{ICE-1234}{Introduction to Algorithms}
\examperiod{s1}
\timeallowed{2}
\nfrom{2}
\calculatorsallowed
\guidance{Answer all questions in Section A and two questions from Section B.}
\begin{document}
\sectiona
\begin{questions}
\question[10] Define the asymptotic notation $O(f(n))$ and give an example.
\begin{solution}
$g(n) \in O(f(n))$ if there are constants $c>0$ and $n_0$ such that
$g(n) \le c\,f(n)$ for all $n \ge n_0$; for example $3n^2+5n \in O(n^2)$.
\end{solution}
\question Which of the following sorting algorithms is stable?
\begin{choices}
\choice Quicksort
\correctchoice Merge sort
\choice Heapsort
\choice Selection sort
\end{choices}
\question Consider binary search on a sorted array of $n$ elements.
\begin{parts}
\part[5] State its worst-case running time.
\begin{solution}
$O(\log n)$.
\end{solution}
\part[5] Explain why the array must be sorted.
\begin{solution}
Each comparison discards the half that cannot contain the key, which
is only valid if the elements are in order.
\end{solution}
\end{parts}
\end{questions}
\sectionb
\begin{questions}
\question[25] Describe Dijkstra's algorithm and prove that it computes
shortest paths when all edge weights are non-negative.
\begin{solution}
A greedy algorithm that settles the unsettled vertex of least tentative
distance; the proof is by induction on the set of settled vertices.
\end{solution}
\question[25] Explain dynamic programming using the longest common
subsequence problem as an example.
\begin{solution}
Define $L[i,j]$ for prefixes of both strings and fill the table row by
row in $O(mn)$ time.
\end{solution}
\question[25] Compare hash tables and balanced binary search trees for
implementing a dictionary.
\begin{solution}
Expected $O(1)$ versus worst-case $O(\log n)$ operations; trees keep the
keys in order.
\end{solution}
\end{questions}
\end{document}
The first page, as this template compiles today. Click it to enlarge, and again to shrink. Open the file ↗