subject

You are playing a board game in which you move your pawn along a path of n fields. each field has a number l on it. in each move, if your field carries the number l, then you can choose to take any number of steps between 1 and l. you can only move forward, never back. your goal is to reach the last field in as few moves as possible. below we've written a recursive algorithm to find the optimal strategy for a given board layout. the input to the algorithms is an array board containing the numerical value in each field. the first field of the game corresponds to board [0] and the last to board [n-1]. here we use python or range so range(a, b) consists of integers from a to b-1 inclusively. recursive_moves (array board, int l, int n ): # board has length n and contains only positive integers. if l == n-1: return 0 min_so_far = float('inf') for i in range (l + 1, min(l + board [l] +1, n)): moves = recursive_moves (board, i, n) if (moves + 1 < min_so_far): min_so_far = moves + 1 return min_so_far 1.1. (1 pt.) run recursive moves (board, o, len(board)) with the input array (1,3,6, 3, 2, 3, 9,5). write down a list of all the distinct calls to the function (making sure to note the value of input l) and the return values. it's ok to "memoize" as you go. 1.2. (2 pts) show that the algorithm is correct. it will to formulate a claim of the form: "on input l, the algorithm correctly finds the number of moves needed to get from position x to position y of the board" (for some values of x and y that depend on l). 1.3. (1 pts.) show that the running time of recursive moves (board, 0, len(board)) (as written, with no memoization) on an input array of size n is 12(2"). 1.4. (1 pts) for how many distinct values of the inputs will the algorithm make recursive calls on inputs of size n? 1.5. (3 pts.) write pseudocode (or working code) for a memoized version of the recursive moves procedure that runs in polynomial time. 1.6. (3 pts.) write pseudocode (or working code) for a nonrecursive "bottom-up" version of the recursive moves procedure that runs in polynomial time. note that "bottom-up" here does not necessarily mean in increasing order of l; it means from the simplest subproblems to the most complicated ones. (hint: you might want to program your algorithms yourself to test them. they should be short and esay to code. 1.7. (1 pts.) analyze the asymptotic worst-case running time of your algorithms on input arrays of size n. (the two algorithms will probably be the same).

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 08:40
1. the program must provide following functions to extract some statistics. note that the data_list parameter specified in these functions may be the same for all functions or different for different functions—that is your choice. a skeleton file is provided on mirmir. a) open_file()prompts the user to enter a year number for the data file. the program will check whether the year is between 1990 and 2015 (both inclusive). if year number is valid, the program will try to open data file with file name ‘year.txt’, where is the year. appropriate error message should be shown if the data file cannot be opened or if the year number is invalid. this function will loop until it receives proper input and successfully opens the file. it returns a file pointer and year. i. hint: use string concatenation to construct the file name b) read_file(fp)has one parameter, a file pointer read. this function returns a list of your choosing containing data you need for other parts of this project. c) find_average(data_list) takes a list of data (of some organization of your choosing) and returns the average salary. the function does not print anything. hints: i. this is not the average of the last column of data. it is not mathematically valid to find an average by finding the average of averages—for example, in this case there are many more in the lowest category than in the highest category. ii. how many wage earners are considered in finding the average (denominator)
Answers: 1
question
Computers and Technology, 23.06.2019 18:50
What is transmission control protocol/internet protocol (tcp/ip)? software that prevents direct communication between a sending and receiving computer and is used to monitor packets for security reasons a standard that specifies the format of data as well as the rules to be followed during transmission a simple network protocol that allows the transfer of files between two computers on the internet a standard internet protocol that provides the technical foundation for the public internet as well as for large numbers of private networks
Answers: 2
question
Computers and Technology, 24.06.2019 18:30
These factors limit the ability to attach files to e-mail messages. location of sender recipient's ability to open file size of file type of operating system used
Answers: 1
question
Computers and Technology, 25.06.2019 01:00
Your computer will organize files into order. alphabetical chronological size no specific
Answers: 2
You know the right answer?
You are playing a board game in which you move your pawn along a path of n fields. each field has a...
Questions
question
Mathematics, 17.03.2021 23:40
question
Mathematics, 17.03.2021 23:40
question
Mathematics, 17.03.2021 23:40
Questions on the website: 13722360