


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



As a first step go to the last page and read the section: Advice on how to do the homework.
For each of the following problems indicate which algorithmic approach (Greedy , Divide-and-conquer, Dynamic programming, Max-flow) you would use to attempt to solve the problem. You do not have to give an algorithm. (a) In an n × n array, a peak is an element that is greater than its four neighbours (left, right, top and bottom). Peaks can also lie on edges or corners, they are greater than their three or two (respectively) neighbours. There can be more than one peak in an array. Come up with an algorithm that efficiently finds a peak in an n × n array. (b) A computer network is a graph where the vertices are computers and the (undirected) edges indicate a physical network link between two computers. A computer sends a message to another computer on the network by passing it along the network links until it reaches its destination. Find an algorithm that can determine if an eavesdropper that has the ability to monitor messages on up to k network links can intercept every message sent from s to t. (c) You are in charge of assigning planes to gates at an airport. After a plane lands, it needs to be assigned to a gate, where it must remain until it takes off. Given a list of plane arrival and departure times, come up with an algorithm that assigns planes to gates in an efficient manner. (d) Your small town has grown large enough that it has to be divided into suburbs to efficiently allocate resources (e.g. electricity, water, school zones). Come up with an algorithm that assigns households into five “geographically close” suburbs – i.e. divide houses into five groups so that the minimum distance between houses in different suburbs is maximized.
(e) Come up with an algorithm for determining how many ways you can make a total t by summing k numbers (possibly repeated) from a set S.
Give a detailed algorithm for one of the problems in Question 1. Make sure to include:
For each of the following problems, decide if the provided answer correctly solves the problem. If it does then analyse the running-time of the algorithm. If it does not, give an example demonstrating why not. (a) Problem: In a weighted directed graph, find the longest simple (i.e. no repeated vertices) path between two vertices s and t. Solution: Multiply all edges by −1 and, using the Bellman-Ford algorithm, find the shortest path between s and t in the new graph. This will be the longest path in the original graph. (b) Problem: In a connected weighted graph with distinct edge weights, find the spanning tree with maximum weight. Solution: Order the edges by weight from smallest to largest. Remove edges following this order, as long as removing an edge does not disconnect the graph. When all edges have been processed, the remaining edges form the maximum spanning tree. (c) Problem: In a binary tree, find the size of the smallest subset of vertices V^0 such that every edge has at least one endpoint in V^0. Solution: Using dynamic programming. Define M [ v,i ] for every vertex v of the tree and i ∈{ 0 , 1 } as follows:
All submitted work must be done individually without consulting someone elses solutions in accordance with the Universitys Academic Dishonesty and Plagiaris m policies.