0% found this document useful (0 votes)
6 views3 pages

2015 Adsa

This document is an examination paper for the Honour School of Computer Science, Mathematics and Computer Science, and Computer Science and Philosophy, focusing on Advanced Data Structures and Algorithms. It includes questions on amortized analysis, flow networks, online advertising algorithms, linear programming, and scheduling problems. Candidates are instructed to answer no more than two questions and to start each answer on a new page.

Uploaded by

my5dog8
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views3 pages

2015 Adsa

This document is an examination paper for the Honour School of Computer Science, Mathematics and Computer Science, and Computer Science and Philosophy, focusing on Advanced Data Structures and Algorithms. It includes questions on amortized analysis, flow networks, online advertising algorithms, linear programming, and scheduling problems. Candidates are instructed to answer no more than two questions and to start each answer on a new page.

Uploaded by

my5dog8
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

A10399W1

SECOND PUBLIC EXAMINATION


Honour School of Computer Science
Honour School of Mathematics and Computer Science
Honour School of Computer Science and Philosophy

Advanced Data Structures and Algorithms

TRINITY TERM 2015


Friday 5th June, 2:30 pm – 4:00 pm

Candidates should answer no more than two questions.


Please start the answer to each question on a new page.

Do not turn over until told that you may do so.

–1–
Question 1
This is a question about amortised analysis.

(a) Briefly describe the accounting method in amortised analysis. (4 marks)

(b) In class we have argued that the total cost of 𝑛 Increment operations on a 𝑘-bit binary
counter (implemented as an array 𝐴[0..𝑘 − 1] of bits) is 𝑂(𝑛). Is this still the case for a
𝑘-bit decimal counter (implemented as an array 𝐴[0..𝑘 − 1] where the entries of 𝐴 can take
values between 0 and 9)? Justify your answer. (5 marks)

(c) Consider again the 𝑘-bit binary counter. Suppose that the cost of changing the value of
the 𝑖-th bit, 𝑖 = 0, . . . , 𝑘 − 1, is 2𝑖 . What is the best upper bound you can prove on the
total cost of 𝑛 Increment operations? (7 marks)

(d) A deque is a double-ended queue data structure. It supports the following four operations:

∙ Add-Front(𝑥): add 𝑥 to the front of the sequence;


∙ Add-Back(𝑥): add 𝑥 to the back of the sequence;
∙ Remove-Front(): remove and return the front element of the sequence;
∙ Remove-Back(): remove and return the back element of the sequence.

Sketch how to implement a deque on top of three stacks with 𝑂(1) additional storage so
that the amortised running time of each of these four operations is 𝑂(1).
Hint: Use one of the stacks as temporary storage. (9 marks)

Question 2
(a) Define the notions of flow network, flow, and cut. (4 marks)

(b) Consider the following flow network where edge capacities are indicated on the edges and
also we have a lower bound ℓ𝐵𝐶 = 4 on the flow along 𝐵𝐶. Determine whether this
network admits a feasible circulation with vertex demands given by 𝑑𝐴 = −6, 𝑑𝐵 = −3,
𝑑𝐶 = 4, 𝑑𝐷 = 5, by reducing this problem to a max flow problem in an extended network
and using Edmonds–Karp algorithm to find a max flow. (6 marks)

B
5 3

A 9 D
2 5

A10399W1 –2–
(c) Use the definition of a feasible circulation with demands to show that if there exists
a∑feasible circulation with demands {𝑑𝑣 }𝑣∈𝑉 in a flow network with vertex set 𝑉 then
𝑣∈𝑉 𝑑𝑣 = 0. (7 marks)

(d) An online advertising company would like to match users to ads. It is given a set of users
𝑁 = {𝑢1 , . . . , 𝑢𝑛 } and a set of ads 𝐴 = {𝑎1 , . . . , 𝑎𝑚 }. Moreover, there are 𝑘 possibly
overlapping demographic groups 𝒮 = 𝑆1 , . . . , 𝑆𝑘 , with 𝑆ℓ ⊆ 𝑁 for all ℓ (e.g. ‘female’, ‘age
19–24’, ‘owns a car’). Each user 𝑢𝑖 belongs to a subset of demographic groups 𝒮 𝑖 ⊆ 𝒮,
and for each ad 𝑎𝑗 there is a subset of demographic groups 𝒮𝑗 ⊆ 𝒮 that this ad can be
shown to.
The goal of the company is to maximise the number of impressions (i.e. pairs (𝑖, 𝑗) such
that user 𝑢𝑖 is shown the ad 𝑎𝑗 ), subject to the following constraints: (i) each user can
be shown at most one ad; (ii) ad 𝑎𝑗 can only be shown to users in ∪𝑆∈𝒮𝑗 𝑆. Design an
algorithm that finds the maximum number of impressions under these constraints; the
running time of your algorithm should be polynomial in 𝑛, 𝑚, and 𝑘. (8 marks)

Question 3
(a) Define the standard form and the slack form of a linear program. (4 marks)

(b) Define the Vertex Cover problem. Describe an integer linear program for computing a
minimum-size vertex cover and its LP relaxation. Give an example of a graph on which the
optimal value of the LP relaxation is non-integer; explain how you computed the optimal
value. (6 marks)

(c) Consider the following scheduling problem. We are given 𝑛 jobs 𝑇1 , . . . , 𝑇𝑛 ; the size of
job 𝑇𝑖 is 𝑡𝑖 . We are also given 𝑚 machines 𝑀1 , . . . , 𝑀𝑚 ; the speed of machine 𝑀𝑗 is 𝑠𝑗 .
Each job can be split among several machines; the completion time of machine 𝑀𝑗 is 𝐿𝑗 /𝑠𝑗 ,
where 𝐿𝑗 is the total size of fractional jobs assigned to machine 𝑀𝑗 .
Design a linear program that assigns all jobs to machines so as to minimise the makespan,
i.e. the maximum completion time. (5 marks)

(d) Define what it means for a solution to a linear program to be an extreme point solution.
(1 mark)

(e) Describe an integer linear program for the problem of finding a maximum matching in a
bipartite graph, and its LP relaxation. Argue that each extreme point solution for this LP
is integer (and therefore represents a valid matching). (9 marks)

A10399W1 –3– LAST PAGE

You might also like