{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

HW6 solutions - Homework#6 Solutions 1 Napoleon Bonaparte...

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

View Full Document Right Arrow Icon
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 .
Image of page 1

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

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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern