pset7 - Introduction to Algorithms Massachusetts Institute...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Introduction to Algorithms Massachusetts Institute of Technology Professors Shafi Goldwasser and Silvio Micali November 14, 2003 6.046J/18.410J Handout 23 Problem Set 7 This problem set is due in class on Wednesday, November 26. Reading: Chapters 25.1-25.2, 26.1-26.3. There are five problems. Each problem is to be done on a separate sheet (or sheets) of threehole punched paper. Mark the top of each sheet with your name, the course number, the problem number, your recitation section, the date, and the names of any students with whom you collaborated. Problem 7-1. Shortest Paths Consider a given directed weighted graph in which all edge weights are positive. Suppose that you have already computed a distance matrix , where is the length of the shortest path from node to node . @¦ 8¦ 5¦ $967643  %¦"£ '&$#! @ 3 ¢      ¨¦ ¤ ©§¥£ 3 @ ¢ ¡ (a) Give an algorithm that, on input from to that passes through both and . 8 @ 3 3 5 0£ 21)(  A£ CB)( @ 3 8 algorithm that, on input and , outputs a shortest - path in , (c) Give an i.e. your algorithm should output a list of vertices such that .) Problem 7-2. All-Pairs Shortest Paths v A£ s7B)( ¡ @ Ued6baaa©Y6W4UT3 ¢ c8¦```¦X8¦V8 ¢ @ @¦ 3£ u$4t!  A Q IG A£ SR4PHBE( Xg ¢  8 ¦ X q 8£ R#26srPp#i ih c f Give an implementation of the F LOYD -WARSHALL algorithm that uses Problem 7-3. Transitive Closure space. We define a directed graph to be edge-parsimonious if among all directed graphs with the same transitive closure as , graph has a minimum number of edges. (See CLR pages 632– 633 for a definition of transitive closure.)  ¨ ¤£ xwt)( Given a directed acyclic graph , give an with the same transitive closure as . ¡ ¡ q ¡ algorithm that finds an edge-parsimonious graph Problem 7-4. Greedy Maximal Matching.  ¨¦ ¤£ x6§¥€y¡ ¢ Give a linear time algorithm that, on input graph half that of a maximum matching. , finds a matching with size at least ¤D FE8 algorithm that, on input and , outputs a list of all vertices (b) Give an that is on some shortest path from to . q ¡ % q q ¡ " , finds the length of the shortest path such ¡ 2 Problem 7-5. Flying Friends to San Francisco Handout 23: Problem Set 7 You are stuck in San Francisco and you want to fly as many friends as possible from Boston to San Francisco to celebrate your birthday tommorrow. You have a schedule of flights available to you today. An entry in this schedule is described by five values : = starting city = ending city = departure time = arrival time = number seats available  ‰¦ ˆ ¦  ¦@¦ 3£ r$&4©¥4©‡&$t†t…„ƒ ¢ A   ‚  †3  r‰  4  4ˆ  &@ ‘ ‘ ‘ ‘ ‘ Give an efficient algorithm that determines the maximum number of friends you can fly from Boston to San Francisco in time for your birthday party using the flights from schedule . You may assume that all flights run precisely on time, and that transfers between flights are instant (i.e., for flights and and , then it is possible for one student to take flight and if then flight ). Be sure to argue correctness and analyze the running time of your algorithm. Hint: You might want to transform the schedule into a max-flow instance and then solve the maxflow instance. You may use any max-flow algorithm as a black box.  ƒ  3 ©—–&@ ¢  i  –  „  2•”’ˆ “ ...
View Full Document

This note was uploaded on 01/01/2011 for the course CS 5503 taught by Professor Charlese.leiserson during the Fall '01 term at MIT.

Ask a homework question - tutors are online