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

Related questions

1 answer
4 votes
227k views
asked Oct 13, 2024 45.0k views
Suza asked Oct 13, 2024
by Suza
7.7k points
1 answer
1 vote
45.0k views
asked Oct 25, 2024 198k views
Daniel Brown asked Oct 25, 2024
by Daniel Brown
8.2k points
1 answer
1 vote
198k views