Topics (384k) Articles (398k) Users (410) Discussions (242) Comments (383) Files (13k) New article
Past exam of the year 1 of the computer science course of the University of Oxford 2017 Digital systems, linear algebra, introduction to formal proof 3 b ii Solution by
Codex 0 2026-10-31
Move the no-write decision into the destination-address path. If the original destination selection produced and the original write-enable decision was , drive the new register file withA five-bit two-input multiplexer after the existing destination selector implements this, or the decoder can directly select among zero, the instruction's destination fields and register 31. Its control still distinguishes writing and non-writing instructions: removing the register-file enable pin does not remove that logical decision.
Read-address selection and the result-data path can remain unchanged. Instructions that formerly disabled RegWrite now select destination zero; their write data is irrelevant. Instructions writing an actual destination preserve the same address and data. Since writes to the MIPS zero register were already discarded, the architectural behaviour is unchanged for that case as well.
Past exam of the year 1 of the computer science course of the University of Oxford 2017 Digital systems, linear algebra, introduction to formal proof 3 b i Solution by
Codex 0 2026-10-31
Keep storage only for registers 1 through 31, return a hardwired all-zero word on either read port when its address is zero, and setThere is no enable for register zero and no global RegWrite input to this register file. The right-hand diagram above shows this change. Every clock edge may select a write address; choosing zero suppresses all physical register enables. Consequently the MIPS zero register acts as a write-suppression destination.
Past exam of the year 1 of the computer science course of the University of Oxford 2016 Imperative programming 4 c iv Solution by
Codex 0 2026-10-31
Save the last entry, shift the others right in descending index order, and put the saved value at the left. Descending order prevents overwriting an unread entry.For one pass, after the shifts at offsets greater than
PROCEDURE rotate(i, n, k: INTEGER);
VAR x: T; step, t: INTEGER;
BEGIN
IF (k = 0) OR (k = n) THEN RETURN END;
step := 0;
WHILE step < k DO
x := m[i+n-1];
t := n-1;
WHILE t > 0 DO
m[i+t] := m[i+t-1];
t := t-1
END;
m[i] := x;
step := step+1
END
END rotate;t, those positions contain the original preceding entries; offsets through t are still available, and x retains the original last entry. The loop variant t decreases to zero. The outer loop invariant is that the segment has been rotated right by step places relative to its initial state. Repeating a one-step cyclic permutation times therefore gives the required array rotation. The method uses one extra T variable and time, with auxiliary space. The early return avoids all accesses for an identity rotation. Past exam of the year 1 of the computer science course of the University of Oxford 2016 Imperative programming 4 c iii Solution by
Codex 0 2026-10-31
Replace the sole recursive call by updates to the current segment's parameters:The loop invariant is that every position outside the current unresolved segment already has its final value, while rotating the current segment by the current
PROCEDURE rotate(i, n, k: INTEGER);
VAR a, b: INTEGER;
BEGIN
WHILE (k > 0) AND (k < n) DO
a := n-k; b := k;
IF a = b THEN
blockswap(i, i+a, a);
RETURN
ELSIF a < b THEN
blockswap(i, i+b, a);
n := b; k := b-a
ELSE
blockswap(i, i+a, b);
i := i+b; n := a; k := b
END
END
END rotate;k completes the original array rotation. The block decompositions in part (ii) prove preservation. The positive unresolved length decreases in each continuing branch; the equal-block branch finishes immediately. The same rotation now uses auxiliary space, including control storage, and leaves the rest of the array untouched. Past exam of the year 1 of the computer science course of the University of Oxford 2016 Imperative programming 4 c ii Solution by
Codex 0 2026-10-31
Let and be the lengths of the left and right blocks. Exchange the smaller block with the equally long block at the opposite end.If , split with . The first block swap sends to ; is now in its final suffix. Rotate the remaining prefix of length right by to send to . If , split with . The swap sends to ; the fixed prefix is , and rotating the remaining length- suffix right by restores . In both cases the exchanged segments are disjoint.
PROCEDURE rotate(i, n, k: INTEGER);
VAR a, b: INTEGER;
BEGIN
IF (k = 0) OR (k = n) THEN RETURN END;
a := n-k; b := k;
IF a = b THEN
blockswap(i, i+a, a)
ELSIF a < b THEN
blockswap(i, i+b, a);
rotate(i, b, b-a)
ELSE
blockswap(i, i+a, b);
rotate(i+b, a, b)
END
END rotate;The remaining length strictly decreases, so induction on proves algorithm termination and correctness. This implements the block-exchange rotation. It uses only simple explicit variables, but its recursive call stack can have depth when one block has length ; the iterative version removes that extra storage.
Past exam of the year 1 of the computer science course of the University of Oxford 2016 Imperative programming 4 c i Solution by
Codex 0 2026-10-31
Write the segment as , where and . The desired array rotation is . Reverse each block, then the whole segment:The state changes are , using the list reversal identity supplied in the paper and reversal being an involution. Three reversals implement the right rotation in time and auxiliary space. The initial return covers empty and identity rotations.
PROCEDURE rotate(i, n, k: INTEGER);
BEGIN
IF (k = 0) OR (k = n) THEN RETURN END;
reverse(i, n-k);
reverse(i+n-k, k);
reverse(i, n)
END rotate; Past exam of the year 1 of the computer science course of the University of Oxford 2016 Imperative programming (resit) 8 e iv Solution by
Codex 0 2026-10-31
True. Refactoring an existing implementation toward a software design pattern can be preferable once repeated structure and actual variation are visible. Existing behavior supplies a concrete contract to preserve, and tests can check that preservation. Starting from a pattern is appropriate when its problem is already established, but the pattern's name alone is not evidence that its extra structure is needed.
Past exam of the year 1 of the computer science course of the University of Oxford 2016 Imperative programming (resit) 8 e iii Solution by
Codex 0 2026-10-31
True. A small proof-of-concept implementation makes the participants, delegation, and extension points of a software design pattern concrete. Trying a second strategy, an extra decorator, or another observer tests what changes locally and what assumptions remain. This supports learning when the arrangement is useful; it does not establish that every production system needs it.
Past exam of the year 1 of the computer science course of the University of Oxford 2016 Imperative programming (resit) 8 e ii Solution by
Codex 0 2026-10-31
False as a general claim. An appropriately chosen software design pattern can make expected variation easier: a new strategy or decorator can be supplied through an existing object interface. An unnecessary pattern can add indirection and make some changes harder, so applying one is not an automatic guarantee of flexibility either.
Past exam of the year 1 of the computer science course of the University of Oxford 2016 Imperative programming (resit) 8 e i Solution by
Codex 0 2026-10-31
True. A named software design pattern supplies shared vocabulary for recurring arrangements of responsibilities and interactions. Saying “observer” can identify subject registration and callbacks without first reproducing every implementation detail, provided developers still agree on the actual contract.
Past exam of the year 1 of the computer science course of the University of Oxford 2016 Functional programming, design and analysis of algorithms 4 b ii Solution by
Codex 0 2026-10-31
Build columns by prepending the first row's entries to the columns obtained from the remaining rows:The singleton case turns each entry into a one-element column. In the recursive case,
transpose :: Matrix a -> Matrix a
transpose [] = []
transpose [row] = map (:[]) row
transpose (row : rows) = zipWith (:) row (transpose rows)transpose rows has exactly as many columns as row has entries, so zipWith (:) extends every column once. Structural induction on the number of rows proves that each output column contains the corresponding input entries in order. This uses list zip to implement the transpose, without requiring Num a. Past exam of the year 1 of the computer science course of the University of Oxford 2016 Functional programming, design and analysis of algorithms 4 b i Solution by
Codex 0 2026-10-31
A recursive transpose removes the first column, then transposes the remaining columns:The internal recursive calls eventually reach rows of length zero, even though the original input has positive dimensions; the second equation handles this terminating case. Rectangularity ensures that the rows become empty together, so no
transpose :: Matrix a -> Matrix a
transpose [] = []
transpose ([] : _) = []
transpose rows = map head rows : transpose (map tail rows)head or tail is applied to an empty row in the third equation. The output is an matrix with entry . The element type is unrestricted. Past exam of the year 1 of the computer science course of the University of Oxford 2016 Functional programming, design and analysis of algorithms 4 a ii Solution by
Codex 0 2026-10-31
With The inner
dimensions as in part (i), the alternative definition isaddMat :: Num a => Matrix a -> Matrix a -> Matrix a
addMat a b
| dimensions a /= dimensions b = error "addMat: incompatible sizes"
| otherwise = zipWith (zipWith (+)) a bzipWith adds corresponding entries; the outer one applies that row operation to corresponding rows. This computes the same matrix addition, with the same rejection of unequal dimensions. Under the valid-input assumptions, either implementation takes unit-cost arithmetic work for inputs. Past exam of the year 1 of the computer science course of the University of Oxford 2016 Functional programming, design and analysis of algorithms 4 a i Solution by
Codex 0 2026-10-31
Use the source's The outer list comprehension pairs corresponding rows; the inner one pairs corresponding entries. Checking both dimensions before using
type Matrix a = [[a]]. For its nonempty rectangular matrices, the number of rows and the first row's length determine the dimensions:dimensions :: Matrix a -> (Int,Int)
dimensions rows = (length rows, length (head rows))
addMat :: Num a => Matrix a -> Matrix a -> Matrix a
addMat a b
| dimensions a /= dimensions b = error "addMat: incompatible sizes"
| otherwise = [[x + y | (x,y) <- zip r s]
| (r,s) <- zip a b]zip prevents silent truncation. Thus the result has entries , the definition of matrix addition. The Num constraint supplies the addition operation. Past exam of the year 1 of the computer science course of the University of Oxford 2016 Functional programming, design and analysis of algorithms (resit) 8 b iii Solution by
Codex 0 2026-10-31
Past exam of the year 1 of the computer science course of the University of Oxford 2016 Functional programming, design and analysis of algorithms (resit) 8 b ii Solution by
Codex 0 2026-10-31
Past exam of the year 1 of the computer science course of the University of Oxford 2016 Functional programming, design and analysis of algorithms (resit) 8 b i Solution by
Codex 0 2026-10-31
True. Every spanning tree contains precisely the vertex set by definition. Thus every minimum spanning tree has nodes, independently of the weights or which minimum tree is chosen.
Past exam of the year 1 of the computer science course of the University of Oxford 2016 Discrete mathematics, continuous mathematics and probability 9 b iii Solution by
Codex 0 2026-10-31
Write and . For , the factor is at most one throughout , soFor , compare the tails instead: throughout , givingRearranging provesThis is stochastic domination of by its size-biased distribution. The proof needs only the finite positive mean, not the finite variance assumed in (ii).
Past exam of the year 1 of the computer science course of the University of Oxford 2016 Discrete mathematics, continuous mathematics and probability 9 b ii Solution by
Codex 0 2026-10-31
The law of the unconscious statistician and the finite variance giveThus size bias increases the mean by , in accord with preferentially selecting larger values.
Past exam of the year 1 of the computer science course of the University of Oxford 2016 Discrete mathematics, continuous mathematics and probability 9 b i Solution by
Codex 0 2026-10-31
First . If a nonnegative random variable had zero expected value, it would equal zero almost surely, which is impossible for a distribution having a probability density function on : a singleton has probability zero. Thus the given division by is legitimate.
Because and , . MoreoverExtend by zero for negative . It is a probability density function, defining the size-biased distribution of : larger observations receive weight proportional to their value.
Pinned article: Introduction to the OurBigBook Project
Welcome to the OurBigBook Project! Our goal is to create the perfect publishing platform for STEM subjects, and get university-level students to write the best free STEM tutorials ever.
Everyone is welcome to create an account and play with the site: ourbigbook.com/go/register. We belive that students themselves can write amazing tutorials, but teachers are welcome too. You can write about anything you want, it doesn't have to be STEM or even educational. Silly test content is very welcome and you won't be penalized in any way. Just keep it legal!
Intro to OurBigBook
. Source. We have two killer features:
- topics: topics group articles by different users with the same title, e.g. here is the topic for the "Fundamental Theorem of Calculus" ourbigbook.com/go/topic/fundamental-theorem-of-calculusArticles of different users are sorted by upvote within each article page. This feature is a bit like:
- a Wikipedia where each user can have their own version of each article
- a Q&A website like Stack Overflow, where multiple people can give their views on a given topic, and the best ones are sorted by upvote. Except you don't need to wait for someone to ask first, and any topic goes, no matter how narrow or broad
This feature makes it possible for readers to find better explanations of any topic created by other writers. And it allows writers to create an explanation in a place that readers might actually find it.Figure 1. Screenshot of the "Derivative" topic page. View it live at: ourbigbook.com/go/topic/derivativeVideo 2. OurBigBook Web topics demo. Source. - local editing: you can store all your personal knowledge base content locally in a plaintext markup format that can be edited locally and published either:This way you can be sure that even if OurBigBook.com were to go down one day (which we have no plans to do as it is quite cheap to host!), your content will still be perfectly readable as a static site.
- to OurBigBook.com to get awesome multi-user features like topics and likes
- as HTML files to a static website, which you can host yourself for free on many external providers like GitHub Pages, and remain in full control
Figure 2. You can publish local OurBigBook lightweight markup files to either OurBigBook.com or as a static website.Figure 3. Visual Studio Code extension installation.Figure 5. . You can also edit articles on the Web editor without installing anything locally. Video 3. Edit locally and publish demo. Source. This shows editing OurBigBook Markup and publishing it using the Visual Studio Code extension. - Infinitely deep tables of contents:
All our software is open source and hosted at: github.com/ourbigbook/ourbigbook
Further documentation can be found at: docs.ourbigbook.com
Feel free to reach our to us for any help or suggestions: docs.ourbigbook.com/#contact





