Discrete Mathematics and Its Applications, Seventh Edition

Published by McGraw-Hill Education
ISBN 10: 0073383090
ISBN 13: 978-0-07338-309-5

Chapter 3 - Section 3.1 - Algorithms - Exercises - Page 203: 32

Answer

procedure maxsum $( a_1, a_2, a_3, ... a_n:$ a sequence of integers $)$ currentsum $:= a_1$ Initialize a list RESULT to contain all values $\alpha$ such that $a_{\alpha}>\sum_{i = 1}^{\alpha-1} a_i$ for $m :=2$ to $n$ $\space\space\space$ if $a_m>$ currentsum then add $a_m$ to RESULT $\space\space\space$ currentsum $:= $ currentsum $+ a_m$ return RESULT

Work Step by Step

This algorithm attempts to find the set of integers such that they are greater than the sum of the previous terms. It does this by comparing each integer to the sum attained to the point; adding it to the result set if it satisfies the condition and then updating the sum as required.
Update this answer!

You can help us out by revising, improving and updating this answer.

Update this answer

After you claim an answer you’ll have 24 hours to send in a draft. An editor will review the submission and either publish your submission or provide feedback.