HW6 solutions

HW6 solutions - Homework#6 Solutions 1 Napoleon Bonaparte the great French Emperor and ruthless military genius 1 seeks to establish efficient

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

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

Unformatted text preview: Homework #6 Solutions 1. Napoleon Bonaparte, the great French Emperor and ruthless military genius 1 seeks to establish efficient administrative communication between Paris and n other provinces in France through one-way broadcast messages from Paris along pre-specified paths. There are k different languages spoken across the French empire, and thus a lot of consecutive translations may need to happen along the way to a remote province when a message is sent. Each province speaks just one of k languages. Napoleon’s messengers carry message scrolls from Paris (in French) along a graph G = ( V,E ) of roads and sailing routes. Each message scroll has a specific destination t . Only three-way intersections are present, which means that at each intersection the messenger has exactly 2 choices (since one of the paths leads back the way they came). At each intersection lies a checkpost where scrolls come and the message is translated to the language required of the next node in the path. The emperor has a k × k matrix, C, of positive numbers for the cost C ( i,j ) of translating from language i to language j . The translation costs in the matrix are not necessarily symmetric. Design an efficient algorithm to output the path which minimizes the total cost of the translation to get a scroll from Paris to t , and analyze the running time. Solution: This problem was poorly worded and open to multiple interpretations. Any reasonable interpretation of the problem, correctly solved, is worth full points. 2. We are given a graph where each edge e has an integer time t ( e ) > 0, representing the time it takes to traverse the edge, and an integer cost c ( e ) > 0 representing the cost in dollars to traverse the edge. We have D dollars at our disposal, and want to find the shortest path from s to t such that the total cost is no more than D . (a) Give a dynamic programming algorithm to determine the length of the shortest path subject to the above constraints, and analyze the running time. Solution For each node, we define d ( v,K ) to be the length of the shortest path from s to v which has cost at most K . If we compute this for every v ∈ G and every integer 0 ≤ K ≤ C , then we will have a solution to the problem (the length we’re looking for is d ( t,C ) and we can backtrack to find the path). We can define these terms recursively as: • If K < 0, then d ( v,K ) = ∞ • If K = 0, then d ( s, 0) = 0 and d ( v, 0) = ∞ if v 6 = s ....
View Full Document

This note was uploaded on 12/13/2010 for the course CSCI 570 at USC.

Page1 / 5

HW6 solutions - Homework#6 Solutions 1 Napoleon Bonaparte the great French Emperor and ruthless military genius 1 seeks to establish efficient

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online