Answered step by step
Verified Expert Solution
Question
1 Approved Answer
This homework must be solved using a Dynamic Programming or / and Greedy Approach. Other approaches used to solve this homework won t get credit.
This homework must be solved using a Dynamic Programming orand Greedy Approach.
Other approaches used to solve this homework wont get credit.
can you draw the diagram with the answer with step by step and also showing the arrow to every possible points that can go around, if can't go explain why for this my question
thank you.
You are in a new city C where all the streets in this city cross each other at different points.
Your goal is to find out the length of the shortest path to walk from building A to building B in
miles The city has the following layout:
Street S index layout, is one way, width, length
Index: an integer from to N that represents the index of the street in the citys
layout. Note that two different streets with vertical and horizontal layout may have
the same streets index.
Layout: an integer value represented by or defining the layout of the street in
relation to other streets in the city.
Value : vertical street
Value : horizontal street
Is one way: an integer value represented by or that defines whether the street is
oneway or not
Value : False
Value : True
Width: a decimal value that represents the width of the street in miles, from the left
side to right side of the street.
Length: an decimal value that represents the length of the street in miles, from the
starting point to the end point of the street.
Building X street position, location
Street: a street S representing the street where the building is located
Position: an interger value represented by or :
Value : right side of the street
Value : left side of the street
Location: An interger value represented by :
Value : the building is located at the start of the street
Value : the building is located at the middle of the street
Value : the building is located at the end of the street
P erson P BX BY intersection, direction, distance traveled
Bx: Building X is the source building
By: Building Y is the destination building
Intersection: the point where two streets intersect represented by a tuple with two streets
Sv Sh where Sv is a vertical street, and Sh is a horizontal street
Direction: a char value defining the direction this person is taking at any point in the
process.
r: right
l: left
d: down
u: up
Distance traveled: A decimal value representing the distance traveled so far by this
person.
City Policies:
Streets in City C do not have sidewalks. They only have a median strip where people
can walk down as pedestrians
If a specific street is oneway orand a deadend, then this rule applies for pedestrians
too.
Once a person exits from a building, this person must be directed towards the median
strip that is located in front of the building, this walked distance must also be considered
in your final answer.
Once a person has reached the destination, and in order to enter the destination building,
this person must leave the median strip, cross the street and enter the building that will
be located in front of the median strip. This walked distance must also be considered in
your final answer.
The following is an example of an instance of this problem statement:
Given a city C with a list of N streets S buildings Bx and By and person P as follows:
C
Bx C; By C
PBx ByC Cl
Find the minimum distance P needs to travel from Bx to By in city C
points Design an optimized algorithm for this problem using a Dynamic Programming
orand Greedy approach. You can use the example instance of this problem given in the
problem statement, but you will need to prove that your algorithm works for any instance of
this problem not only for the given example The design of your algorithm must include
diagrams of your city showing every step in your algorithm, and short written stepbystep
instructions explaining at the high level how your algorithm works. Show ALL your
work to get credit. Algorithm designs using approaches other than Dynamic
Programming orand Greedy wont get credit for this homework assignment
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started