Question: Answer all in C++ please 1Suppose you are trying to bind many books together (for whatever reason you can think of). The books may consist

Answer all in C++ please

1Suppose you are trying to bind many books together (for whatever reason you can think of).

The books may consist of a different number of pages. For example, Book A can have 12 pages and Book B can have 500 pages.

Each time you bind two books together the total effort to perform the binding is equal to the number of pages in both books. For example, Binding Book A and Book B will require 512 units of effort.

Write a program that takes in one line of input. The line of input will be the number of pages for each book separated by commas.

Your program must output the minimum units of effort required to bind all the books together.

Input: 100,12,6,40

Output: 234

NB: The best way to bind these books is to firstly bind 12 with 6 which costs 18 units of effort. We now have books of sizes {100, 18, 40}. We then can bind 18 and 40, which costs 58 units of effort. We now have books of sizes {100, 58}. And finally we bind 100 and 58 which requires 158 units of effort. Thus we required 18+58+158 = 234 units of effort.

Input: 900,46,34,187,23,100,2541,3987

Output: 13692

Input: 187,65,13,4,5,89,13,55,4,99,544

Output: 2480

2

Write a program which takes in a complete proper binary tree. Your program will check if the inputted tree is a binary search tree. If it is your program must output TRUE or FALSE otherwise.

Just as in the lab on trees, the tree will be inputted into the computer layer-by-layer starting at the root. Input it terminated with -1.

Input:

1

2

3

4

5

6

-1

Output: FALSE

Input:

9

5

15

1

8

12

-1

Output: TRUE

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!