Question: Problem 2 Starting with a map represented by a rectangular grid with height h and width w. Cells are numbered (0,0) in the top left

 Problem 2 Starting with a map represented by a rectangular grid

Problem 2 Starting with a map represented by a rectangular grid with height h and width w. Cells are numbered (0,0) in the top left to (h1,w1) in the bottom right. Each cell in the grid is either empty or contains an impassable object. All movements on the map are done as a single step to a cell that is adjacent horizontally or vertically. No diagonal movement is permitted. (a) [10 points ] Write an algorithm (pseudo-code) that uses a breadth first search to find the length of the shortest path from (0,0) to (w1,h1). Return 1 if no such path exists. (b) [10 points ] What is the worst case complexity for your algorithm? Be sure to specify how the input size is measured and show your work. (c) [10 points ] Modify your algorithm from part (a) to return the shortest path from (0,0) to (w1,h1) in addition to its length. How does your change affect the time complexity? How does your change affect the amount of memory required

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!