• Support@bestrushessays.com +1 (616) 682 7436 Fast, accurate, original and Top Quality Work

Assignment: Dynamic Programming

Solve a problem using top-down and bottom-up approaches of Dynamic Programming technique

Two players A & B are playing a game. The rules of the game are:

At the start one number N will be given. The player who starts would have to pick a number i such that 0<i<N, the condition is that N%i == 0. The second player would pick a number j from N-i, satisfying the condition 0<j<(N-i). And the game goes on until there is no more possibility of making any selection. Each player would play in turns, andA always starts the game. Assume both players play optimally.

Given a number N return if A would win the game or not. Example 1:Input: N=2, Result: True Explanation: A choses 1, and B has no more numbers to chose

Example 2:Input: N=3, Result: False Explanation: A choses 1, B choses 1, and A has no more numbers to chose

a. Implement a solution to this problem using Top-down Approach of Dynamic Programming, name your function game_topdown(N)

b. Implement a solution to this problem using Bottom-up Approach of Dynamic Programming, name your function game_bottomup(N)

c. Explain your approach to solve this problem. How is your top-down approach different from the bottom-up approach?

d. What is the time complexity and Space complexity using Top-down Approach

e. What is the time complexity and Space complexity using bottom-up Approach

f. Write the subproblem and recurrence formula for your approach name your file Game.py

You Need a Professional Writer To Work On Your Paper?

 

Have any Assignment?

 




.

X

You cannot copy content of this page

error:
Get a Price Quote