199k views
0 votes
Tabulate and list every variable and every value change when you trace, use the Divide and Conquer versions of the Algorithms:

1. x to n(3,9) (how many multiplications?)
2. max_subsequence_sum_1 ([5,−1,−6,3,7,−8]) only when i=0 and i=1
3. max_subsequence_sum_2([5,-1,-6,3,7,-8])
4. max_subsequence_sum_3 ([5,−1,−6,3,7,−8])
5. max_subsequence_sum_3([-2,1,5,-3,8,-4,2,-1)

User Standage
by
8.5k points

1 Answer

6 votes

Final answer:

The algorithm x to n(3,9) has a variable x that changes from 3 to 9. The max_subsequence_sum_1 algorithm has a variable i that changes from 0 to 1. The max_subsequence_sum_2 and max_subsequence_sum_3 algorithms have no variables that change.

Step-by-step explanation:

Solution A:

For the algorithm x to n(3,9), the variable is x and the value changes from 3 to 9. The number of multiplications depends on the algorithm implementation.

For the algorithm max_subsequence_sum_1 with the list [5,-1,-6,3,7,-8], the variable is i and the value changes from 0 to 1.

For the algorithm max_subsequence_sum_2 with the list [5,-1,-6,3,7,-8], there are no variables that change.

For the algorithm max_subsequence_sum_3 with the list [5,-1,-6,3,7,-8], there are no variables that change.

For the algorithm max_subsequence_sum_3 with the list [-2,1,5,-3,8,-4,2,-1], there are no variables that change.

User Robin Qiu
by
8.7k points