Solutions to all three questions of the University of Oxford computer science finals paper, Trinity Term 2018, held on 16 June 2018. Every printed option is treated.
Source: Public examination-paper archive, member 2017/T/a16156w1.pdf, paper A16156W1, three scanned pages. The printed 2018 cover controls the sitting despite the archive member’s directory name.
A binary search tree is a binary tree storing distinct keys from a total order, with every key in a node's left subtree smaller than that node's key and every key in its right subtree larger. The condition concerns entire subtrees, not just immediate neighbours.
For membership, start at the root of a tree and compare the target with the current key. Return true on equality; continue into the left subtree for a smaller target and the right subtree for a larger target; return false on an empty subtree. The binary search tree ordering ensures that a discarded subtree cannot contain the target. Each step descends one level, so the algorithm terminates and uses time complexity for height of a binary tree , under constant-time key comparison.
First perform splaying on the key to be deleted, making its node the root of a tree. Delete that root, leaving left and right subtrees . If either is empty, return the other. Otherwise find the maximum key of by following right-child references, and perform splaying on within . This makes the root of with an empty right subtree. Attach there. The result is the original splay tree with exactly the selected key removed. An unsuccessful lookup leaves the represented set unchanged.
For algorithm correctness, all keys of are smaller than the deleted key, and all keys of are larger. Splaying preserves the binary search tree property by the permitted assumption. Since is the maximum of , it has no larger key within ; since every key of exceeds , attaching as its right subtree preserves every ordering condition. All remaining keys occur once. This is the join-based deletion of a splay tree.[ref]
No. In a red-black tree with no red nodes, equal black height forces every graph path from the root to an absent-child position to have the same length. A real node cannot have exactly one real child: the two paths through that node would then have different numbers of black nodes. Recursively, every real level must be full. The tree is therefore a perfect binary tree.
With real levels its size is . A size of would require , which is impossible for an integer . The black null sentinels are not counted among the stored entries. This is the all-black red-black tree size criterion.
Use the conventional bottom-up red-black tree insertion: insert a red node by the binary search tree rule, repair a red parent with recolouring or tree rotations, and make the root black. Write and for black and red. The first three insertions give root , with on the left and on the right.
Inserting as the left child of gives a red parent and a red uncle. Recolour black and retain a black root . Inserting then gives the inner configuration ––. A left tree rotation at , followed by a right tree rotation at , produces a subtree rooted at with and beneath it. Finally insert to the left of . Its uncle is red, so recolour black and red. No further repair is required because has black parent .
The final root is ; its left child is and its right child is . Under are on the left and on the right; has left child . All omitted children are black null sentinels. Each root-to-null graph path has two real black nodes, and no red node has a red child.
Figure 1.
The red-black tree after the six insertions, with colours also marked B and R
. Details.
Write . After splaying on , that key is at the root, and is the smallest key in its right subtree. This uses the integer assumption: no stored key lies strictly between and . Thus has an empty left subtree while it remains within the right subtree of .
Now perform ordinary bottom-up splaying on . Until the final step involving , all tree rotations occur below and leave it at the root. There are only two possible final cases.
  • If is the right child of , a single zig step rotates above , placing immediately to its left.
  • Otherwise is a grandchild of . Its parent lies in the right subtree of and must satisfy . Hence the last two directions are right then left. A zig-zag step rotates above and then above , again placing immediately to its left. A right-right final configuration is impossible because is the minimum of this subtree.
Therefore becomes the left child of . The argument applies more generally to consecutive keys in a binary search tree, even when their numerical difference is not one.
Use the usual bottom-up splaying operations. We prove the stronger result that at most three successful calls suffice. No insertions or deletions are needed.
If the chosen key is the minimum stored key, first perform splaying on and then on its immediate successor. The argument for consecutive keys in a binary search tree makes the left child of the successor with an empty right subtree; minimality makes its left subtree empty too. Hence is a leaf of a rooted tree. The maximum-key case is the mirror image.
Suppose is an interior key. Since at least four keys are stored, there are either two keys larger than or two smaller than . In the former case choose four consecutive stored keys
where is the predecessor of , and are the next two successors. Perform .
Here is a complete check of the local shapes. After the first call, is the root. After the second, is the root; every key below is in its left subtree , and every key above stays in the right subtree of . These outside subtrees cannot interfere with the next search. Between and there are only . The last step of splaying on is either a zig step, leaving as its right child; a zig-zag step, with the same result; or a zig-zig step, leaving some as its right child with immediately to the right of . Consequently the possible right subtrees of are exactly among these four forms, using for a node with its left and right subtrees:
Here an unexpanded or denotes a node with no children. Each row follows by the indicated one or two tree rotations in each bottom-up step. All rows end with as the right child of , with both its subtrees empty. If instead two keys below are available, reflect the construction, exchanging left and right and reversing the order of keys. This proves splaying a chosen node into a leaf for every node of every splay tree of size at least four.
For a finite undirected graph , a vertex cover is a subset meeting every edge: for every , at least one of belongs to . The optimization problem asks for a vertex cover of minimum cardinality. Its usual decision version also supplies an integer and asks whether one exists with .
Construct a set cover problem instance whose universe is the set of edges . For each vertex , supply the set of all edges incident to . A collection covers the universe if and only if every edge has an endpoint in , which is precisely the vertex cover condition.
The correspondence preserves cardinality: a vertex cover of size is a feasible solution of the set cover problem using of these sets, and conversely. If two labelled vertices produce identical sets, one can keep their labels or discard duplicate choices without changing the optimum. The construction has size when incidences are listed, so it is a polynomial-time reduction.
Root the tree arbitrarily. For each vertex , let be the minimum vertex cover size in its descendant subtree, conditional on selecting , and the corresponding minimum conditional on omitting . Process the vertices in postorder traversal. For every child of ,
At a leaf of a rooted tree, the empty sums give . Return at the root .
For algorithm correctness, if is selected, each child subtree may independently use its cheaper state, since the connecting edge is already covered by . If is omitted, each child must be selected to cover its connecting edge. Distinct child subtrees have no edges between them because the input is a tree. These observations prove the recurrences by structural induction. Each edge contributes constant work once, giving time complexity and space with adjacency lists. The single-vertex tree correctly has optimum zero. This is minimum vertex cover of a tree by dynamic programming.
In depth-first search of an undirected graph, every edge joins a vertex to one of its ancestors or descendants in the discovery tree. To see this directly, suppose is discovered before its neighbour . If is still undiscovered, the search from cannot finish before discovering : it eventually scans . Thus is discovered while the call for remains active and belongs to its descendant subtree.[ref]
For any edge , its ancestor endpoint therefore has a proper descendant and hence at least one child. It is an internal vertex of a rooted tree. Every edge has an internal endpoint, so the internal vertices form a vertex cover. The relevant leaves of a rooted tree here have no children in the rooted discovery tree; a root of vertex degree one can still be internal.
We construct an injection from the unmatched vertices in a matching to the leaves of a rooted tree. Start a downward graph path at each unmatched vertex . If the current vertex is a leaf of a rooted tree, stop. Otherwise choose any child . The current vertex is either the unmatched starting point or a vertex already matched to its own parent.
In either case, cannot be unmatched: the proper matching in a rooted tree condition would require its parent to be matched to one of 's siblings in a rooted tree, whereas that parent is either unmatched or already matched upward. Nor can be matched to its parent. Its matching partner must therefore be one of its own children, say . Extend the graph path by the two edges to and then to , and continue from .
Every extension descends two levels, so finiteness guarantees termination at a leaf of a rooted tree. Every visited vertex except the starting point is matched. The constructed graph paths for different unmatched starting points are disjoint: if two downward graph paths in a tree meet, one starting point must lie on the other path, which would put a second unmatched vertex after the first. That is impossible. Hence their terminal leaves of a rooted tree are distinct, proving
Only the properness condition for unmatched non-root vertices was used. If the root is unmatched and the convention exempts it because it has no parent, the same construction starts there and still works. Thus the root convention does not affect the claimed inequality. This proves the unmatched-vertex bound for a proper tree matching without requiring to have maximum size.
For a connected graph with at least one edge, run depth-first search and output the set of internal vertices of a rooted tree in its discovery tree . Part (d) proves that is a vertex cover. It is also connected: every ancestor of an internal vertex is internal, so the graph path in from that vertex to the root stays inside . The root is internal when .
For the approximation guarantee, choose a maximum-size proper matching in a rooted tree of , whose existence is supplied. It is used only in the analysis; the algorithm need not construct it. Since every matched edge uses two distinct vertices,
By part (e), . Therefore
The final inequality holds because every vertex cover of , connected or otherwise, must use at least one distinct endpoint for each of the disjoint edges in . Thus this is a 2-approximation algorithm in time complexity.
For completeness, a disconnected input needs a feasibility check: if two different connected components of a graph contain edges, no connected vertex cover can meet both. If exactly one component contains edges, run the construction on that component and ignore isolated vertices. If there are no edges, the empty vertex cover is optimal when an empty solution is permitted; if a nonempty connected solution is required, any single vertex is optimal for a nonempty input. These conventions cover the boundary cases omitted from the main approximation argument.
Use the standard maximum form of a linear program
An arbitrary linear program can be converted by the following operations.
  • Replace minimization of by maximization of , and negate the resulting optimal value when translating back. A constant term in the objective is recorded separately.
  • Replace every unrestricted variable by with both new variables nonnegative. A nonpositive variable can instead be negated. A lower bound can be eliminated by writing , ; other bounds remain linear inequalities.
  • Multiply a row by . Replace an equality by the pair and .
These substitutions preserve the attainable objective values, up to the stated sign and constant corrections, and map feasible points in both directions. An alternative standard-form convention uses : add a nonnegative slack variable to each upper-bound row, or subtract a nonnegative surplus variable from a lower-bound row. The inequality convention above is used in the remaining solutions.
Let be the set of isolated vertices of the finite simple graph . Introduce a nonnegative integer for every vertex. Use the integer program
Every nonisolated vertex belongs to an edge, whose inequality and the other endpoint's nonnegativity already imply . The explicit bounds on therefore make all variables binary. For an integer feasible point, is an independent set, and its cardinality is the objective. Conversely the indicator vector of any independent set is feasible. Thus the optimal value is the maximum independent set size. Including the isolated-vertex bounds is essential for an arbitrary graph; without them the formulation would be unbounded whenever an isolated vertex is present.
Remove the integer requirements from the previous formulation to obtain its linear programming relaxation. Give each edge constraint a nonnegative dual variable , and each bound for a nonnegative dual variable . Since all right-hand sides are one, the dual linear program is
An integer feasible point selects a multiset of edges touching every nonisolated vertex, together with at least one singleton for each isolated vertex. Repeated edges or singleton choices can be discarded without losing coverage, so an optimum has a genuine edge cover of the nonisolated part and one singleton per isolated vertex. If has no isolated vertices, this is exactly an edge cover, with the objective counting selected edges including any unnecessary multiplicities. The isolated-singleton extension is necessary because a graph with an isolated vertex admits no ordinary edge cover.
This interpretation concerns integer feasible dual solutions. The linear programming relaxation can have fractional optima, so its value need not equal the integer independent set optimum. For example, the triangle has relaxed independent-set value , whereas its maximum independent set has size and its minimum edge cover has size .
Regard the two kinds of agents as the two sides of a complete bipartite graph, with edge weight . Pairing everyone is a perfect matching, and its maximum total weight is . Consider the capacitated linear program
It is feasible and bounded. Every optimum has all row and column sums equal to one: otherwise the equal total deficits of the two sides give a row and column both below one. Increasing by the smaller of their positive deficits remains feasible and increases the objective because , a contradiction.
Thus an optimum is a doubly stochastic matrix. By the Birkhoff-von Neumann theorem it is a convex combination of permutation matrices, so at least one corresponding perfect matching has weight at least its objective. Conversely every such perfect matching gives a feasible matrix. Hence . One way to justify the decomposition is to apply Hall's marriage theorem to the positive-entry support, subtract the smallest entry on a supported perfect matching, and repeat after rescaling the nonzero remainder; each subtraction removes a positive entry, so the process terminates.
The dual linear program assigns nonnegative dual variables to the row and column capacity constraints:
These are exactly the permitted payments and all the pairwise acceptance conditions, so its optimal value is . It is feasible, for example by taking and . Strong duality now gives . In particular, the nonnegative payment restriction has been retained throughout; using capacity inequalities rather than equality constraints avoids introducing unrestricted prices.
For a direct weak duality check, sum over any pairing . Its revenue never exceeds the company's total offered payment. The linear programming duality and integrality argument prove that this lower bound on payments is attained.
Combine all inequalities, including nonnegativity, into ; explicitly, the rows encode . Let be a vertex of a linear polyhedron, equivalently an extreme point of the feasible linear polyhedron, and let index the active constraints there.
Suppose the active row normals have rank smaller than . By the rank-nullity theorem there is a nonzero vector with for every . Every inactive row has positive slack variable value . Since there are only finitely many rows, choose so small that
Then both and are feasible points: the active constraints remain equalities and no inactive inequality is violated. They are distinct, and is their midpoint, contradicting the extreme point property.
Therefore the active row normals have rank , and at least linearly independent constraints are satisfied with equality. In particular at least constraints are tight, as claimed. Nonnegativity bounds must be counted: for example, at the origin these can supply all active rows. Degeneracy can make more than constraints tight, so the result does not assert exactly .
Source paper: released examination archive, member 2017/T/a15684w1.pdf. The printed cover dates this examination to 29 May 2018. All three questions and all eighteen lettered parts are answered below. The stag-hunt arguments distinguish the intended positive rewards from the zero-reward boundary omitted in the printed assumptions.
For a finite normal-form game, a mixed strategy is a probability distribution over player 's pure strategies. Independent randomization by the players defines an expected payoff . A strategy profile is a Nash equilibrium if
for every player and every alternative mixed strategy . By linearity in a player's own distribution, it is enough to check all pure deviations. Equivalently, every pure strategy in the support of a mixed strategy must be a best response to the other players' choices.
With rows and columns ordered Head, Tail, the payoff matrix of ordered pairs is
This is a zero-sum game. There is no pure Nash equilibrium: when the coins match, player 1 gains by switching to a mismatch; when they do not match, player 2 gains by making them match. Since , these improvements are strict.
Let and be the respective probabilities that players 1 and 2 choose Head. Player 1's payoffs from Head and Tail are and . Player 2 is indifferent when the corresponding player-1 payoffs against its two pure actions, and , agree. The resulting unique fully mixed Nash equilibrium is
Both numbers lie strictly between zero and one. If either player instead used a pure action, the other's unique best response would force the pure-action cycle above, so there are no additional partly mixed equilibria. Substitution gives player 1's expected payoff and its negative for player 2.
For , the best response correspondences are
Their intersection is , with expected payoffs .
Figure 1.
The two best response correspondences intersect at the unique mixed equilibrium
. The horizontal axis is player 1's Head probability , and the vertical axis is player 2's Head probability . Whole intervals at indifference are included. Details.
Yes: choose . The equilibrium expected payoffs are opposite because this is a zero-sum game. They are equal exactly when both are zero. Part (b)'s value vanishes exactly when , and for every allowed . This establishes both existence and the unique suitable positive choice of .
Under the intended positive rewards , a hunter at the all-hare strategy profile receives . A unilateral switch to deer leaves only one participant. Since the integer threshold satisfies with , we have , so that deer hunt fails and pays zero. Thus no player can gain by switching, and the all-hare profile is a Nash equilibrium. At it remains an equilibrium through indifference; negative would invalidate the claim.
Assume and the feasible threshold . An unsuccessful deer hunter would gain by switching to hare, so an equilibrium with deer participants must have . A deer hunter then earns and must not gain by changing to hare; this requires . A hare hunter who joins would earn , so staying with hare requires . Hence the necessary and sufficient conditions for the stated range are
These conditions check every possible unilateral change in this two-action game, so they also prove sufficiency. Equality is allowed because a Nash equilibrium rules out strict improvements, not indifferent deviations. The endpoint has no hare hunter to check; it is an equilibrium exactly when .
Continue with and set . Part (e) requires an interior count to satisfy with ; the all-deer endpoint is allowed when . If is nonintegral and , only works. If is an integer with , both and work. At only remains, while permits only . When , there is no positive equilibrium count.
Thus there are at most two positive counts, and exactly one precisely when
This includes , when the excluded set is empty. It counts numbers of deer hunters, not the many choices of which hunters participate. The argument is the threshold stag-hunt equilibrium count.
The original paper states only explicitly. Its assertion needs the usual strict positivity of the hare reward. If zero is included, take . Counts and both give unsuccessful hunters zero, and one additional deer hunter still cannot reach the threshold; all unilateral alternatives also pay zero. The count is an equilibrium as well. These are three positive equilibrium counts, contradicting an unrestricted reading. More generally, for , the positive counts are and .
A game tree is a rooted tree representing successive histories. A nonterminal vertex specifies the player who moves, its outgoing edges are the available actions, and each leaf specifies a terminal payoff for every player. A pure strategy specifies an action at every decision point belonging to that player, including decision points not reached by the eventual play.
For a perfect-information game, each player observes the exact preceding history. An extensive-form game with imperfect information additionally groups indistinguishable decision points into information sets, with compatible available actions. Chance moves, if present, carry specified probabilities; the displayed game has none. A subgame perfect equilibrium must prescribe a Nash equilibrium in every proper subgame as well as in the whole game.
Apply backward induction in games, or Zermelo's algorithm, from the terminal decision points. At node 4, player 1 chooses because , giving continuation payoffs . At node 5, player 1 chooses because , giving . At node 3, player 2 compares its continuation payoffs nine and six, so chooses . At node 2, player 2 chooses , receiving four rather than two.
At the root, player 1 consequently receives six from either action: leads to and to . Thus there are two pure subgame perfect equilibria, with strategies
The semicolon separates the players, and each list specifies the player's action at every one of its decision points. All four non-root choices are strict. If mixed strategies are included, every mixture between and at the root is also an equilibrium, with those other actions fixed. There are no further mixtures at the strict decision points.
For each history of the first two votes, voter 3 selects its favourite achievable winner. Writing rows for voter 1's vote and columns for voter 2's vote, the resulting continuation winners are
For example, after votes , voter 3 can make either or win, and prefers ; a vote for would instead produce the tie-break winner .
Voter 2 prefers to to . Optimizing each row therefore gives continuation winners after voter 1's respective choices . Voter 1 prefers to and therefore votes , giving winner in every subgame perfect equilibrium.
Some histories admit several equally good votes, but they produce the same winning candidate. Since each voter strictly ranks the three possible winners, unique outcome under strict outcome preferences makes this winner independent of those action ties. This is backward induction over outcomes, not a claim that the entire equilibrium strategy profile is unique.
Yes: let the order be voter 2, then voter 3, then voter 1. When voter 1 moves last, it makes win whenever that is possible; otherwise it prefers to . For the first two votes in this new order, its optimal continuation winners are
Rows now record voter 2's initial choice and columns voter 3's choice. In a three-way split, the specified tie-break produces , which explains, for example, the off-diagonal entry.
Voter 3 optimizes its ranking in each row, giving the continuation winners . Voter 2 then chooses , its favourite of the three. The winner is therefore in every subgame perfect equilibrium, again by unique outcome under strict outcome preferences. In particular, if voter 2 starts with , voter 3 must also vote : either other vote lets the last voter force .
In the final round, player 1 strictly accepts every . In any subgame perfect equilibrium it must also accept with probability one. Otherwise, if that acceptance probability were , offering zero would give player 2 only . A sufficiently small positive offer would be accepted and yield more. No positive offer maximizes player 2's payoff either, because a smaller positive offer improves it. The same supremum argument rules out a mixed offer distribution attaining the missing maximum. Thus the final-round equilibrium uniquely has , accepted, with payoffs .
In round one, player 2 therefore rejects and accepts . At it is indifferent, but equilibrium again forces acceptance with probability one: if acceptance were less likely, player 1 could improve on any proposed optimum with an offer just above . Since , player 1 strictly prefers the resulting positive payoff to rejection.
Consequently the unique equilibrium outcome is immediate agreement at , giving payoffs . The full strategies are: player 1 offers initially and accepts every nonnegative final offer; player 2 accepts initial offers at least , rejects smaller ones, and offers zero in every reached final-round subgame. These prescriptions cover off-path histories too. Acceptance at indifference follows from the continuous-offer bargaining acceptance lemma, rather than an arbitrary tie-breaking convention.
Let be the initial proposer's share, measured as a fraction of the pie currently available, with rounds remaining. The last-round argument in part (e) gives . Rejecting an offer leaves the responder as next proposer with a pie smaller by factor , so its continuation value is . The current proposer offers exactly that amount, which is accepted by the continuous-offer bargaining acceptance lemma. Hence
The formula follows by summing a finite geometric series, or by induction in the recurrence. Agreement is immediate in every subgame, so this share is player 1's actual initial payoff.
For odd , lies above and decreases with . For even , lies below that value and increases with . Thus prefer odd to even, fewer rounds among odd choices, and more rounds among even choices. For the given , this simplifies to choose if is odd, and choose if is even. All comparisons are strict because . This is the finite-horizon bargaining parity effect.
For an -player transferable utility game with , the Shapley value is
It averages player 's marginal contribution over uniformly random orders of all players. Exactly of the permutations put precisely before . For a cooperative cost game, apply the same linear formula to the cost function; the result represents payments instead of distributed benefits.
Take three players and define the simple cooperative game
It is a superadditive coalitional game: two disjoint coalitions cannot both have value one because each would need player 1. If one has value one, their union does too; if neither does, the desired inequality is immediate.
The vector belongs to the core of a cooperative game. More strongly, it is the unique core vector: singleton constraints give nonnegative coordinates, efficiency gives sum one, and the value-one coalitions and force .
In a random player ordering, player 1 is pivotal unless it comes first, giving Shapley value . Player 2 is pivotal only in order , and player 3 only in order . Thus
The coalition receives only , so the Shapley value is outside the core. This proves that superadditivity and nonempty core do not imply Shapley stability.
Put . For nonempty coalitions, the runway required by a union is the longer of the two required runways, so
The inequality uses nonnegative costs and also holds when either coalition is empty. Thus the cost function is subadditive, in particular for the stated disjoint coalitions. A subadditive cost game becomes a superadditive coalitional game after changing signs to .
Choose one plane requiring the longest runway and assign it the entire cost ; assign every other plane zero. These nonnegative payments sum to . Any coalition containing that chosen plane also requires the whole longest runway, so its payment is exactly its standalone cost. Any coalition without it pays zero, which is at most its nonnegative standalone cost.
Hence this payment vector is in the cost core, proving the desired sharing always exists. This is an existence certificate, not a fairness assertion. If there are no planes, the empty allocation has total zero. The Shapley value of an airport game gives a more symmetric sharing rule and also lies in the core of this cooperative cost game.
Decompose the required runway into successive layers. The first layer has cost and is needed by all four planes. The next costs and is needed by the three medium-or-long planes. The final layer costs and is needed only by the longest plane.
For each layer, the first requiring plane in a uniformly random ordering contributes its entire cost. Each of its requiring planes has equal probability of being first. By linearity of the Shapley value, divide each layer cost equally among those requiring it. The payments are therefore
They sum to . The equality of the two medium payments follows from their identical runway requirements; the random-order argument proves the amounts, not just their equality.
Remove any plane types with zero count, retaining the increasing order of the remaining lengths; if none remain, return the empty allocation. For the retained types put and . Then every plane of type has Shapley value
Compute suffix counts in a backward pass. In a forward pass, accumulate and output as the common payment for type .
For correctness, layer costs and is required by exactly planes. A particular requiring plane is earliest among these in a random ordering with probability . Its expected marginal contribution to the layer is therefore that layer's cost divided by . Summing the layers it requires proves the formula. This is the Shapley value of an airport game.
The two passes use arithmetic operations. If every individual payment must be explicitly listed, add the unavoidable output work. For counts given in binary, the compact per-type output is polynomial in the input size; expanding an exponentially large number of identical entries need not be. With integer lengths and rational , all fractions can be computed exactly with polynomial bit complexity: a common denominator divides a product of at most suffix counts, whose bit length is , in addition to the input denominator of . For arbitrary real , the same rational factors give symbolic multiples of it.

Articles by others on the same topic (0)

There are currently no matching articles.