# Exercise 1

You are given a long string of letters, *w *= (*w*_{1}*,…,w _{n}*). You are interested in the longest palindrome, i.e. the longest sequence

*P*= (

*w*) that is the same forwards and backwards, meaning (

_{i},…,w_{j}*w*

_{i},w_{i}_{+1}

*,w*

_{i}_{+2}

*,…,w*

_{j}_{−1}

*,w*) = (

_{j}*w*−

_{j},w_{j}_{1}

*,w*−

_{j}_{2}

*,…,w*

_{i}_{+1}

*,w*).

_{i}- Give an algorithm that in
*O*(*n*^{2}) time outputs the longest palindrome, and prove its running time. - Give an algorithm for the case that the palindrome does not have to be a continuous subsequence of
*w*, i.e. the case that it is any sequence*P*= (*w*_{i}_{1}*,w*_{i}_{2}*,…,w*_{i}) for which (_{j}*w*_{i}_{1}*,w*_{i}_{2}*,…,w*_{i}) = (_{j}*w*_{i}_{j}*,w*_{i}_{j}_{−1}*,…,w*_{i}_{1}) and*i*_{1 }*< i*_{2 }*<*··*< i*. Show that the algorithm solves the problem in time_{j}*O*(*n*^{3}).

# Exercise 2

You are organizing an event where investors can meet founders of young startups during an evening of interesting presentations and good food. You plan to equip the room with round tables of at least three people each, and to enable fruitful conversations, you plan on arranging the seating such that each investor *i *∈ *I *has only founders *f *∈ *F *as neighbors and vice versa. At the same time, since you know the interests of each investor, you have narrowed down the *good *pairs (*i,f*) into a list *P *⊆ *I *×*F*. Design a flow network *N *such that finding a maximum flow in *N *solves the problem of whether it is possible to find a seating arrangement with only *good *pairings. Make sure you give a formal definition of the vertex and edge set of *N*, and show the correctness of your construction.

# Exercise 3

As a freelance programmer, you work via a website that offers projects. The website has *n *projects *p *∈ *P *that currently interest you, but in order to work on each, you need to have a certain *credit score **c _{p }*to demonstrate the suitability of your skills. Your current score is

*C*. However, working on each project will also influence your credit by some amount

*b*(positive or negative), so after doing one project, your suitability for some of the others might have changed. You can assume that for any

_{p }*p*,

*c*+

_{p }*b*≥ 0. Give an algorithm that finds out whether you can do all

_{p }*n*projects in

*P*in some order, or not. Your algorithm must run in time

*O*(

*n*log

*n*). Prove your algorithm’s correctness and running time.

# Exercise 4

You are tasked with finding the best COVID-19 cure. So far, *n *candidates have been developed, with codenames *c*_{1}*,c*_{2}*,…,c _{n}*. To test a single cure, you can add a small amount of it to a vial containing a viral solution. All of them are somewhat effective, but might require a different dose to kill the virus: for example, it could take

*a*

_{4 }= 42 units of

*c*

_{4 }but only

*a*

_{31 }= 6 units of

*c*

_{31}. After putting a certain amount of a cure in a test vial, to decide if the virus has been eliminated you need to perform a complicated test which requires rare and expensive reagents. Since the world will need a very large amount of the cure, you want to find the most effective one with high precision: i.e., you want the cure

*c*∈ {

_{i }*c*

_{1}

*,…,c*} such that

_{n}*a*is minimal. Specifically, you already know that

_{i }*d*units of any cure will kill the virus and want to find the best one. Describe an algorithm to solve this task, using as few tests as possible.

- Find a deterministic algorithm that uses
*O*(*n*log*d*). - Find a randomized algorithm that uses
*O*(*n*+ log*n*log*d*) tests.

## Reviews

There are no reviews yet.