Manhattan tourist problem mtp manhattan tourist

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: 3 2 1 2 1 2 3 1 2 2 1 0 1 2 1 2 3 2 1 2 0123456789 1 0 1 2 1 2 3 2 1 2 2 1 2 3 c = (1,3,7) M=9 012345 0 2 1 01234 0 1 012345678 0123 0 2 01234567 1 012 0 1 3 This handles the optimal number of coins – what about the denominations? Manhattan Tourist Problem (MTP) Manhattan Tourist Problem (MTP) Imagine seeking a path (from source to sink) to travel (only eastward and southward) with the most number of attractions (*) in the Manhattan grid Imagine seeking a path (from source to sink) to travel (only eastward and southward) with the most number of attractions (*) in the Manhattan grid Source * * * * * * * * * * * *ink S Manhattan Tourist Problem: Formulation 0 Goal: Find the longest path in a weighted grid. 4 5 3 15 j coordinate 2 1 4 19 1 2 20 3 5 2 *ink S 3 2 8 3 13 0 3 4 2 5 6 1 4 * 0 4 5 4 9 * * 3 2 7 3 3 * 4 5 2 0 2 * 2 2 6 4 * * 0 3 1 4 3 * * 1 3 1 i coordinate Output: A longest path in G from “source” to “sink” 0 0 * * MTP: An Example source Input: A weighted grid G w ith two distinct vertices, one labeled “source” and the other labeled “sink” Source 2 23 sink 5 MTP: Greedy Is Not Optimal 1 source 2 3 5 3 1 4 3 5 0 0 0 if i=0 and j=0 return 0 if i=0 return MT(0, j-1) + weight of the edge from (0,j-1) to (0,j) if j=0 return MT(i-1,0) + weight of the edge from (i-1,0) to (i,0) x MT(i - 1,j) + weight of the edge from (i - 1, j) to (i,...
View Full Document

Ask a homework question - tutors are online