Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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. \image text in transcribed.

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

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

The Database Experts Guide To SQL

Authors: Frank Lusardi

1st Edition

0070390029, 978-0070390027

Students also viewed these Databases questions