Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A same is plased on an n x n arid as illustrated in the houre below. A plaver initially can choose to pisce a token

A same is plased on an n x n arid as illustrated in the houre below. A plaver initially can choose to pisce a token on any square o the grid, hen the plaver can move the token either one square down or one square to the right at each step. When the player moves the token off the edge of the board, the game ends for the player. Every square of the grid has a number.

The plaver initially has a score 0. whenever the token lands on a square. the

number of the square is added to the player's score.

The obice of the came is to score as

In the example of the figure below, the plas or ces 8 6 7-3-4 830 points D9 D.acing

the token first on the sin the second row and then moving down. down. right. down. down.

28 501

  1. Design an efficient algorithm to compute the maximum possible score that can be achieved, given an input of n x n array of values. You only need to write the recursive formula and describe how the algorithm would be implemented without needing to write the pseudocode. What is the cost of the algorithm?
  2. In a different version of the game, the player can move the token either one square down, one square right. or one square left at each step. However, to prevent infinite scores. the token cannot land on the same square more than once. Now answer the same questions as in (a). Hint: You may define two recursive functions.
image text in transcribed
Problem 3. A Board Game (35 Points) A game is pluyed on nnnn grid as Illustrated in the figure below, A pliyer taintinlly cong choose to plines a toiken on any square of the grad. Then the player an mone the tokin. eitber one square down of one square to the right at ench mep. When the pleyer meven the tolen of the edge of the board, the game ends for the player. Every square of the grid thes. a number. The player initially has a score 0 : whenever the when labds on a segane, the number of the square is added to the player's score. The object of the game is 10 scote as many poines as possible. In the exampie of the figure below, the player gets 86+73+4=10 points by phacins the token first on the 8 in the second row, and then moving down, down, right, down, down. (a) Design an efficient algorithm to compute the maximum possible score that can be achieved, given an input of nn array of values. You only need to write the recursive formula and describe how the algorithm would be implemented without needing to write the pseudocode. What is the cost of the algorithm? (b) In a different version of the game, the player can move the token either one square down, one square right, or one square left at each step. However, to prevent infinite scores, the token cannot land on the same square more than once. Now answer the same questions as in (a). [Hint: You may define two recursive functions.]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Datacasting How To Stream Databases Over The Internet

Authors: Jessica Keyes

1st Edition

007034678X, 978-0070346789

More Books

Students also viewed these Databases questions