subject
Computers and Technology, 31.12.2019 03:31 ehaynie

Even-odd operations given an array of non-negative integers, perform a series of operations until the array becomes empty. each of the operations gives a score, and the goal is to maximize the overall score, the sum of the scores from all operations. determine the maximum possible score after performing the operations on the array. all operations are 1-indexed, and are defined as follows: 1. for every odd-indexed operation, the score is the sum of all integers present in the array. 2. for every even-indexed operation, the score is the negative of the sum of all integers present in the array. 3. after every operation (odd or even), remove either the leftmost or the rightmost integer from the array. for example: let integerarray = [3, 6, 8] initial score = 0 the operations are as follows: 1. operation 1 is odd, so add the sum of the array to the score. score = 3 + 6 + 8 = 17 choose to delete the rightmost integer (i. e. 8), and now integerarray = [3, 6] 2. operation 2 is even, so subtract the sum of the array from the score. sum = 3 + 6 = 9 and score = 17 - sum = 17 - 9 = 8 choose to delete the leftmost integer (i. e. 3), and now integerarray = [6] 3. operation 3 is odd, so add the sum of the array to the score sum-hand score – 8i sum - 816 - 11 2. uperation 2 is even, so subtract the sum of the array from the score. sum = 3 + 6 = 9 and score = 17 - sum = 17 - 9 = 8 choose to delete the leftmost integer (i. e. 3), and now integerarray = [6] 3. operation 3 is odd, so add the sum of the array to the score. sum = 6 and score = 8 + sum = 8 + 6 = 14 only one element is left. it is both the leftmost and rightmost element, so delete it (i. e. 6), and now integerarray = [ ] the array is now empty, so no further operations are possible. the maximum possible score is 14. function description complete the function getmaximumscore in the editor below. the function must return the maximum possible score after performing all the operations. getmaximumscore has the following parameter: integerarray: an array of integers constraints • 1 s size of integerarray < 103 • 0 s integerarray[i] = 109

ansver
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 12:10, Geo777
1. package newton’s method for approximating square roots (case study 3.6) in a function named newton. this function expects the input number as an argument and returns the estimate of its square root. the script should also include a main function that allows the user to compute square roots of inputs until she presses the enter/return key. 2. convert newton’s method for approximating square roots in project 1 to a recursive function named newton. (hint: the estimate of the square root should be passed as a second argument to the function.) 3. elena complains that the recursive newton function in project 2 includes an extra argument for the estimate. the function’s users should not have to provide this value, which is always the same, when they call this function. modify the definition of the function so that it uses a keyword parameter with the appropriate default value for this argument, and call the function without a second argument to demonstrate that it solves this problem. 4. restructure newton’s method (case study 3.6) by decomposing it into three cooperating functions. the newton function can use either the recursive strategy of project 1 or the iterative strategy of case study 3.6. the task of testing for the limit is assigned to a function named limitreached, whereas the task of computing a new approximation is assigned to a function named improveestimate. each function expects the relevant arguments and returns an appropriate value. 5. a list is sorted in ascending order if it is empty or each item except the last one is less than or equal to its successor. define a predicate issorted that expects a list as an argument and returns true if the list is sorted, or returns false otherwise. (hint: for a list of length 2 or greater, loop through the list and compare pairs of items, from left to right, and return false if the first item in a pair is greater.)
Answers: 1
image
Computers and Technology, 22.06.2019 18:00, crimhill
When is it appropriate to use an absolute reference
Answers: 1
image
Computers and Technology, 23.06.2019 14:30, carter1809
Choose the answers that best complete each sentence. on average, are more expensive than other kinds of postsecondary schools. the cost of room and board includes. to save money, some students attend auniversity in their home state.
Answers: 2
image
Computers and Technology, 23.06.2019 19:30, bevanscory123
What are loans to a company or government for a set amount of time
Answers: 1
You know the right answer?
Even-odd operations given an array of non-negative integers, perform a series of operations until th...

Questions in other subjects: