Question: Solve the problem given in Exercise 8.6 using c++ standard libraries. . You must use recursion. Your code CANNOT use any loops (for, while,

Solve the problem given in Exercise 8.6 using c++ standard libraries. \Solve the problem given in Exercise 8.6 using c++ standard libraries. \..

You must use recursion. Your code CANNOT use any loops (for, while, etc) to cycle through the weights except to calculate sums or to print to the screen.

In addition to just a boolean of can it be balanced, also output the positioning of the masses to achieve balance. the test code will call this function:

Have to use: bool findBalance(int target, const std::vector &weights, 
 std::vector &left, std::vector &right); 

Calculate the positions of the weights such that balance can be achieved (if possible) if it is not possible to balance, return false and set left, right to empty if it is possible, return true and set left, right to the arrangement resulting in balance fill left with the weights necessary to place to the left of center (along with the target) fill right with the weights necessary to place to the right of center balance => left + target == right */

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!