Trusted by Students Everywhere
Why Choose Us?
0% AI Guarantee

Human-written only.

24/7 Support

Anytime, anywhere.

Plagiarism Free

100% Original.

Expert Tutors

Masters & PhDs.

100% Confidential

Your privacy matters.

On-Time Delivery

Never miss a deadline.

Imagine that you are placed on a grid with n spaces in every row and n spaces in every column

Computer Science Apr 20, 2021

Imagine that you are placed on a grid with n spaces in every row and n spaces in every column. You can start anywhere along the bottom row of the grid, and you must move to the top row of the grid. Each time you move, you can either move directly up (staying in the same column, but moving up a row), up and to the left (moving over one column and up one row), or up and to the right (moving over one column and up one row). You cannot move up and to the left if you are in the leftmost row, and you cannot move up and to the right if you are in the right most row.
Each time you move, you are either paid or pay; that is, every legal move from square x to square y is assigned a real value p(x, y). Sure, p(x, y) can also be 0.
Give a dynamic programming algorithm to compute your sequence of moves to receive the maximum payoff to move from the bottom of the grid to the top of the grid. (Your maximum payoff may be negative.) You must calculate the value of the optimal solution (i.e., the payoff) and the solution itself (i.e., the sequence of moves). Again, you can start at any square in the bottom row and end in any square in the top row.

Expert Solution

Answer:

You can refer the following figure to understand different positions in a chessboard.

Now there's this Knight that starts at position A1 which needs to end up at some position XY(eg: D4). The knight can only move in an L shape, i.e., It moves to a square that is two squares away horizontally and one square vertically, or two squares vertically and one square horizontally.

So in our example, the knight starts at A1 and should end up at D4 in some k moves. A movement is counted when the knight makes a horizontal and vertical or vertical and horizontal change in its position(The L- Shaped) as discussed earlier.

The problem is to devise an algorithm that calculates the number of ways the knight can end up at XY from A1 in k moves.

Consider our example (A1 to D4)

XY=D4

Let k=2

We have to calculate N(k,x,y)

N(k,x,y)=8 in this case. From A1, C2 and B3 can be reached in two ways. From C2 and B3, D4 can be reached again in two ways, which gives a total of 8 different ways in 2 moves.

PFA

Archived Solution
Unlocked Solution

You have full access to this solution. To save a copy with all formatting and attachments, use the button below.

Already a member? Sign In
Important Note: This solution is from our archive and has been purchased by others. Submitting it as-is may trigger plagiarism detection. Use it for reference only.

For ready-to-submit work, please order a fresh solution below.

Or get 100% fresh solution
Get Custom Quote
Secure Payment