Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Suppose we have a one-dimensional array of integers, such as this: 3247345 What we want to do is derive a count of the number of

image text in transcribed

Suppose we have a one-dimensional array of integers, such as this: 3247345 What we want to do is derive a count of the number of subsequences that sum to an even number and the number of subsequences that sum to an odd number. Let us develop two tables, Even [i] and Odd[i] whose values at index i are the number of subsequences ending at i that sum to an even number and the number of subsequences ending at i that sum to an odd number. In the spirit of dynamic programming we wish to avoid examining all possible subsequences. Ideally, we would calculate these values from left to right, starting at index 0 . Define two different subsidiary arrays called Even and Odd that give the number of even-summed and odd-summed up to a given position in the array. For example, for the value above, Even [0]=0 and Odd[0]=1 because if we are restricted to the first value 3 , the only possible subsequence is 3 and it sums to an odd number. Even [1]=1 and Odd[1]=2 because the only possible subsequences at that point are (3), (2) and (3,2) and one of them sums to an even value and the other two sum to an odd value. Give recurrence that provides for any position in an array, the number of subsequences that sum to an even number and the number of subsequences that sum to an odd number

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

More Books

Students also viewed these Databases questions

Question

Why might an option be preferred over a futures contract?

Answered: 1 week ago

Question

LO12.2 Create research objectives that are specific and achievable.

Answered: 1 week ago