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 2014 Digital systems, linear algebra, introduction to formal proof 7 c iv Solution by
Codex 0 2026-10-31
Assuming lets the disjunction introduction rule produce the logical disjunction excluded by the premise. This gives a contradiction, so conclude by negation introduction and double-negation elimination:
| Line | Context | Formula | Justification |
|---|---|---|---|
| 1 | Premise | ||
| 2 | Temporary assumption | ||
| 3 | disjunction introduction rule on 2 | ||
| 4 | negation elimination rule on 3, 1 | ||
| 5 | negation introduction rule on 4; discharge 2 | ||
| 6 | double-negation elimination on 5 |
Past exam of the year 1 of the computer science course of the University of Oxford 2014 Digital systems, linear algebra, introduction to formal proof 7 c iii Solution by
Codex 0 2026-10-31
The premise turns an assumed into a contradiction. Use the negation introduction rule to obtain , then the supplied classical double-negation elimination rule:
| Line | Context | Formula | Justification |
|---|---|---|---|
| 1 | Premise | ||
| 2 | Temporary assumption | ||
| 3 | implication elimination rule on 1, 2 | ||
| 4 | negation introduction rule on 3; discharge 2 | ||
| 5 | double-negation elimination on 4 |
Hence . The final classical rule is essential: deriving alone is not yet a proof of in Intuitionistic propositional logic.
Past exam of the year 1 of the computer science course of the University of Oxford 2014 Digital systems, linear algebra, introduction to formal proof 7 c ii Solution by
Codex 0 2026-10-31
Under , the first assumption yields , while the second yields . Apply the implication elimination rule once more to obtain , and discharge the three temporary assumptions:
| Line | Context | Formula | Justification |
|---|---|---|---|
| 1 | Temporary assumption | ||
| 2 | Temporary assumption | ||
| 3 | Temporary assumption | ||
| 4 | implication elimination rule on 1, 3 | ||
| 5 | implication elimination rule on 2, 3 | ||
| 6 | implication elimination rule on 4, 5 | ||
| 7 | implication introduction rule on 6; discharge 3 | ||
| 8 | implication introduction rule on 7; discharge 2 | ||
| 9 | implication introduction rule on 8; discharge 1 |
Past exam of the year 1 of the computer science course of the University of Oxford 2014 Digital systems, linear algebra, introduction to formal proof 7 c i Solution by
Codex 0 2026-10-31
Introduce the three logical implications from the outside in. Under assumptions , , and , apply the implication elimination rule twice, then use assumption discharge in reverse order:
| Line | Context | Formula | Justification |
|---|---|---|---|
| 1 | Temporary assumption | ||
| 2 | Temporary assumption | ||
| 3 | Temporary assumption | ||
| 4 | implication elimination rule on 1, 3 | ||
| 5 | implication elimination rule on 2, 4 | ||
| 6 | implication introduction rule on 5; discharge 3 | ||
| 7 | implication introduction rule on 6; discharge 2 | ||
| 8 | implication introduction rule on 7; discharge 1 |
Thus
Past exam of the year 1 of the computer science course of the University of Oxford 2014 Digital systems, linear algebra, introduction to formal proof 2 e ii Solution by
Codex 0 2026-10-31
The logical file data block index and within-block file offset areDirect pointers cover logical indices 0 through 9. The singly indirect region covers 10 through . The requested file data block therefore lies in the doubly indirect region, at relative indexFollow the doubly indirect block pointer in the inode, read its top address block and select entry 14, read that second address block and select entry 511, then read the resulting file data block and take byte offset 1568. These entry indices are zero-based.This assumes a resident inode and no useful buffer cache entries for the three blocks; an uncached inode adds one read. Under one-based byte numbering the last offset is 1567, without changing either address-block index or the read count.
Past exam of the year 1 of the computer science course of the University of Oxford 2014 Digital systems, linear algebra, introduction to formal proof 2 e i Solution by
Codex 0 2026-10-31
Each address uses bytes, so an address block holds pointers. Use zero-based file offsets. The requested file offset hasThus select direct pointer index 1, read its file data block, and take the byte at offset 952 within it. No address block is needed:Fetching an uncached inode adds one read. If “byte 3000” instead uses one-based numbering, the within-block offset is 951; it is still the second file data block, with the same read count. Pathname lookup is separate from accessing a known inode.
Past exam of the year 1 of the computer science course of the University of Oxford 2014 Digital systems, linear algebra, introduction to formal proof 1 c ii Solution by
Codex 0 2026-10-31
Make the code a leaf procedure called
array_diff, copy the four argument processor registers into the temporaries used above, and replace the final label by a return. The copies are real addu instructions, avoiding an unexplained move pseudo-instruction:array_diff:
addu $t0,$a0,$zero
addu $t1,$a1,$zero
addu $t2,$a2,$zero
addu $t3,$a3,$zero
# insert the code of (i), including its initial zero-count test
# use the local label array_diff_done in place of done
array_diff_done:
jr $ra
sll $zero,$zero,0In the literal insertion, the
done: line from (i) is the array_diff_done: line displayed here; it is not a second return block. Under the usual calling convention, temporary processor registers are caller-saved. This procedure calls no other procedure and changes no saved processor registers, so it needs no stack frame or saved return address.For a 32-bit constant , define and using its unsigned binary representation. Load it with
lui followed by ori; both are single MIPS instructions. For base addresses and count , the main program is:main:
lui $a0,H_A
ori $a0,$a0,L_A
lui $a1,H_B
ori $a1,$a1,L_B
lui $a2,H_C
ori $a2,$a2,L_C
lui $a3,H_N
ori $a3,$a3,L_N
jal array_diff
sll $zero,$zero,0
main_after_call:
# c now contains the differences; continue the main program hereHere each
H_... and L_... is an assembler-time numeric constant, not an executed operation. lui places the high half and clears the low half; ori inserts the low half without sign extension. ThusThe jal instruction saves the return address after its branch delay slot in $ra; jr $ra resumes at main_after_call. A main routine that itself needs to return to a caller must save its incoming $ra before jal and restore it afterwards. Past exam of the year 1 of the computer science course of the University of Oxford 2014 Digital systems, linear algebra, introduction to formal proof 1 c i Solution by
Codex 0 2026-10-31
Use byte addresses, so adjacent 32-bit array elements are four bytes apart. The following MIPS instructions include harmless
sll $zero,$zero,0 instructions in every branch delay slot; the second load is followed by another independent instruction before its value is consumed, also accommodating an early MIPS architecture with a load-use delay. All mnemonics here denote individual machine instructions. beq $t3,$zero,done # n=0: do not access any array
sll $zero,$zero,0
loop:
lw $t4,0($t0) # current a element
lw $t5,0($t1) # current b element
addiu $t0,$t0,4 # advance a; also separates lw from its use
subu $t6,$t4,$t5 # current difference, modulo 2^32
sw $t6,0($t2) # store current c element
addiu $t1,$t1,4
addiu $t2,$t2,4
addiu $t3,$t3,-1 # one fewer element remains
bne $t3,$zero,loop
sll $zero,$zero,0
done:A loop invariant at the head of the loop, after completed iterations, is that the three addresses point to elements , the count is , and every output element before equals the corresponding difference. One iteration reads element , stores its difference and advances to , preserving the loop invariant. The remaining count is a nonnegative loop variant decreasing by one, so the loop ends with .
The code uses
subu to avoid signed-overflow traps: the suffix does not restrict the operands to unsigned values. Its precise result isFor representable signed differences this is exactly . If trapping signed arithmetic is required instead, use sub and assume all differences are representable. The arrays must occupy valid word-aligned storage with no address wrap; the usual separate output array avoids overwriting unread inputs. Past exam of the year 1 of the computer science course of the University of Oxford 2013 Imperative programming 2 b ii Solution by
Codex 0 2026-10-31
Place these methods inside the In the forward traversal, the loop invariant is that
LLBuffer class. The two private insertion methods operate on physical endpoints; the public methods interpret logical endpoints using the reversal flag.private def addFirst(x: Int): Unit = {
val q = new Node(x)
q.next = first
if (first == null) last = q else first.prev = q
first = q
size += 1
}
private def addLast(x: Int): Unit = {
val q = new Node(x)
q.prev = last
if (last == null) first = q else last.next = q
last = q
size += 1
}
def append(x: Int): Unit = {
if (backwards) addFirst(x) else addLast(x)
}
def prepend(x: Int): Unit = {
if (backwards) addLast(x) else addFirst(x)
}
def get(i: Int): Int = {
require(0 <= i && i < size)
val j = if (backwards) size - 1 - i else i
var q: Node = null
if (j <= size - 1 - j) {
q = first
var k = 0
while (k < j) { q = q.next; k += 1 }
} else {
q = last
var k = size - 1
while (k > j) { q = q.prev; k -= 1 }
}
val x = q.value
if (q.prev == null) first = q.next else q.prev.next = q.next
if (q.next == null) last = q.prev else q.next.prev = q.prev
q.prev = null
q.next = null
size -= 1
x
}
def rev: Unit = { backwards = !backwards }q is physical node , with ; its loop variant is . In the backward traversal, q is physical node , with ; its loop variant is . Thus both locate physical index , which is exactly logical index under the abstraction function.Deletion bypasses the chosen linked list node in both directions. Deleting the first or last linked list node updates the corresponding endpoint; deleting the only linked list node sets both endpoints to null. The surviving values keep their physical relative order, so the abstraction function gives precisely the required logical deletion. Each insertion preserves reciprocal links and adds its value at the physical end corresponding to the required logical end. Toggling the flag changes to its list reversal without moving any linked list nodes. ConsequentlyThese are worst-case time complexity bounds in the constant-cost pointer model; total storage is and each operation uses constant auxiliary space.
Past exam of the year 1 of the computer science course of the University of Oxford 2013 Imperative programming 2 b i Solution by
Codex 0 2026-10-31
Use a doubly linked list, store both physical endpoints and its length, and maintain a flag for lazy reversal of a doubly linked list. This makes endpoint insertion and reversal constant time. Finding an arbitrary indexed element takes a traversal from whichever physical endpoint is nearer.Define to be the sequence of values obtained by starting at
class LLBuffer extends ReversableBuffer {
private class Node(val value: Int) {
var prev: Node = null
var next: Node = null
}
private var first: Node = null
private var last: Node = null
private var size = 0
private var backwards = false
// Methods from (ii) go here.
}first and repeatedly following next until null. The representation invariant says that size is nonnegative; size == 0 holds exactly when both endpoints are null; otherwise there are exactly size distinct reachable linked list nodes, the final one is last, first.prev == null, last.next == null, and all neighboring links are reciprocal. These conditions make finite and the physical linked list acyclic. The abstraction function isThe flag does not change the representation invariant. An empty physical linked list represents the empty sequence for either flag value. No client receives a linked list node reference, so clients cannot invalidate its links.Physical doubly linked list order and logical sequence order under lazy reversal of a doubly linked list
. Details. Past exam of the year 1 of the computer science course of the University of Oxford 2013 Functional programming, design and analysis of algorithms 6 c iii Solution by
Codex 0 2026-10-31
Use deterministic median of medians to select the element of rank in worst-case time. Partition the array about that value, retaining the smallest elements. The input is a set, so there are no equal-key ambiguities: take the smaller values and the selected value itself. Sort these elements with merge sort, then output them.
For completeness, median of medians groups values in fives, finds each small group's median, recursively selects a median of those medians as a pivot, and recurses only into the partition containing the requested rank. At least entries lie on each side of the pivot. Its worst-case recurrence isSelection and partitioning cost , and sorting the retained prefix costs for . Including output at givesScanning the input is necessary even to identify its minimum. Ordering the selected distinct values also has the comparison sorting lower bound , so this is asymptotically optimal for the task. A usual randomized Quickselect gives linear expected selection time, but its quadratic worst case would not establish the requested worst-case guarantee.
Past exam of the year 1 of the computer science course of the University of Oxford 2013 Functional programming, design and analysis of algorithms 6 c ii Solution by
Codex 0 2026-10-31
Store the array as a binary heap with min-heap order. Build it bottom-up by sifting down internal nodes in reverse order, rather than inserting all values one at a time. The sum of subtree heights is , so construction costs . Then perform minimum extractions: output the root, move the last remaining entry to the root, and sift it down to restore the heap order.
Each extraction returns the smallest remaining key, so the outputs are the smallest keys in increasing order. For a heap of current size , an extraction takes time. HenceThe tight worst-case bound for this ordinary binary heap implementation isWhen the extraction term is substantial, worst-case extractions follow root-to-leaf paths of logarithmic length; when is small, the linear construction already dominates. The bound stays valid at , since . Building by separate insertions would lose the linear construction bound and is unnecessary.
Past exam of the year 1 of the computer science course of the University of Oxford 2013 Functional programming, design and analysis of algorithms 6 c i Solution by
Codex 0 2026-10-31
Assume . Apply a worst-case comparison sort, such as merge sort or heapsort, to the whole array, then copy its first entries to the output. The copying costs , soThe comparison sorting lower bound makes the full-sort stage tight. For the sample array, the sorted order begins , which is the required prefix for . This method spends time ordering all unreported elements as well.
Past exam of the year 1 of the computer science course of the University of Oxford 2013 Functional programming, design and analysis of algorithms 2 e ii Solution by
Codex 0 2026-10-31
Write , with . At the th step of the left fold, the left operand of list concatenation is the accumulated prefix of length . Fully forcing these concatenations repeatedly copies earlier elements. Including the traversal of the outer list and the whole output spine givesFor singleton inner lists, this becomes , whereas the right fold takes . More generally, for equal positive length , the left fold takes .
An bound is tight in the worst case over length distributions, but is not a tight formula for every distribution: if all elements occur only in the final inner list, all earlier accumulators are empty and the cost is . Lazy evaluation changes when the work happens; it does not remove repeated prefix traversal when the whole result is demanded.
Past exam of the year 1 of the computer science course of the University of Oxford 2013 Functional programming, design and analysis of algorithms 2 e i Solution by
Codex 0 2026-10-31
Let there be inner lists, of lengths , and let . Evaluate the whole output list spine, taking each input element as an already available value. The defining equation
(x:xs) ++ ys = x : (xs ++ ys) shows that list concatenation traverses its left operand, sharing its right operand.The right fold puts each original inner list on the left of exactly one concatenation. Thus its total element traversal is proportional to , and visiting the outer list costs :The term matters when many inner lists are empty. With rows each of length , the bound is . In particular, with uniformly bounded positive row length it is linear in .
Past exam of the year 1 of the computer science course of the University of Oxford 2013 Functional programming, design and analysis of algorithms 1 b ii Solution by
Codex 0 2026-10-31
Both uses of
x in this definition have the same monomorphic type within the body. Write x :: u -> v. The inner application x z forces z :: u and has type v; the outer application x (x z) forces v = u. Thus x :: u -> u. Finally, x (x z) is applied to y, so u must itself be a function type, say a -> b. This givesf :: ((a -> b) -> a -> b) -> a -> (a -> b) -> b
f x y z = x (x z) yThe principal type is thereforeThe argument
x transforms a function into another function of the same type. The body transforms z twice, then applies the resulting function to y; no recursive type equation is required. Past exam of the year 1 of the computer science course of the University of Oxford 2013 Functional programming, design and analysis of algorithms 1 b i Solution by
Codex 0 2026-10-31
In the type signature
map :: (u -> v) -> [u] -> [v], the supplied function is concat :: [[a]] -> [a]. Type inference therefore identifies u with [[a]] and v with [a]. Consequently,map concat :: [[[a]]] -> [[a]]Thus is the principal type. For example,
map concat [[[1],[2,3]],[[4],[]]] gives [[1,2,3],[4]]: it concatenates each inner group, preserving the outermost grouping. Past exam of the year 1 of the computer science course of the University of Oxford 2013 Discrete mathematics, probability and continuous mathematics 9 b ii Solution by
Codex 0 2026-10-31
Let . On , squaring preserves order. Therefore for ,Including the tails gives the cumulative distribution functionDifferentiating on the interior of the support gives the probability density functionThe divergence near zero is integrable: . There is no point mass at zero, and the assigned value of a probability density function at a single endpoint does not affect the probability distribution.
Past exam of the year 1 of the computer science course of the University of Oxford 2013 Discrete mathematics, probability and continuous mathematics 9 b i Solution by
Codex 0 2026-10-31
Assume . An increasing affine map sends the two endpoints to zero and one when and . Solving givesIndeed, for , the cumulative distribution function of the transformed random variable iswhich is the cumulative distribution function of the continuous uniform distribution on .
A decreasing affine map works too, by swapping the endpoints:These are the two possible choices, since the image interval must have endpoints zero and one. The case cannot be transformed into a nondegenerate continuous uniform distribution by deterministic constants.
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






