Question: Robots on Grids Let's consider a robot on an m x n grid of squares ( that is , m rows and n columns )

Robots on Grids
Let's consider a robot on an mxn grid of squares (that is,m rows and n columns). The robot starts in the top-left square, and its target is at the bottom-right. The robot has two moves available to it - it can move one square to the right, or one square down - so it must make a combination of rightward and downward moves to reach its target. It follows that the robot will take (m+n-2) steps to reach its target.|
Here are two such paths it could take:
Your task is to write code that counts the number of possible paths for the robot, given an m and n.
Write a function num paths (m,n) that recursively computes the number of paths from the top-left to bottom-right square of an mn grid without memoization.
Write a function num_paths_memo (m,n) that does the same, but memoizes the smaller subproblem solutions.
The provided sample/driver code will
import time
def num_paths (m,n) :
# TODO: Task 1 of the assignment
def num_paths_memo(m, n):
# TODO: Task 2 of the assignment
#driver code - you do not need to make any changes after this line.
#However, submit a screenshot of the output to report the execution time/elapsed time.
start_time = time.time()
print (num_paths (15,14))
end_time = time.time()
start_time_memo = time.time()
print(num_paths_memo (15,14do the runtime calculation for you. Take a screenshot of the output and submit it along with your python script.
Expectef Output
The expected result for m=15, n=14 is 20058300.
The elapsed time/runtime can vary from system to system.
 Robots on Grids Let's consider a robot on an mxn grid

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!