Concept explainers
This exercise deals with the problem of finding the largest sum of consecutive terms of a sequence of n real numbers. When all terms are positive, the sum of all terms provides the answer, but the situation is more complicated when some terms are negative. For example, the maximum sum of consecutive terms of the sequence -2, 3, -1, 6, -7,4 is
a) Use pseudocode to describe an algorithm that solves this problem by finding the sums of consecutive terms starting with the first term, the sums of consecutive terms starting with the second term, and so on, keeping track of the maximum sum found so far as the algorithm proceeds.
b) Determine the computational complexity of the algorithm in part (a) in terms of the number of sums computed and the number of comparisons made.
c) Devise a divide-and-conquer algorithm to solve this problem. [Hint: Assume that there are an even number of terms in the sequence and split the sequence into two halves. Explain how to handle the case when the maximum sum of consecutive terms includes terms in both halves.]
d) Use the algorithm from part (c) to find the maximum sum of consecutive terms of each of the sequences: -2,4,-1,3, 5, -6, 1, 2 4, 1,-3, 7, -1, -5,3, -2; and -1, 6,3, -4, -5,8, -1,7.
e) Find a recurrence relation for the number of sums and comparisons used by the divide-and-conquer algorithm from part (c).
f) Use the master theorem to estimate the computational complexity of the divide-and-conquer algorithm. How does it compare in terms of computational complexity with the algorithm from part (a)?

Want to see the full answer?
Check out a sample textbook solution
Chapter 8 Solutions
DISCRETE MATH CONNECT ACCESS
- Calibri BIUAAAA ויו Text in Italian is not being checked. Do you want to add it as a proofing language? Task 12 Fig 1 75 75 75 Fig 2 Fig 3j Add Figures 1 to 3 each shows a top view and a front view of models. Make use of the lineated paper for isometric projection and take each block on the paper as being 10mm x 10mm. Use the indicated sizes and draw an isometric view of each of the three models Samsung Galaxy A04earrow_forwarda) show that the empty set and sigletonset are convex set. 6) show that every sub space of linear space X is convex but the convers heed not be true. c) let Mand N be two convex set of a linear Space X and KEF Show that MUN is conevex and (ii) M-N is convex or hot A and is MSN or NSM show that MUN convex or not, 385arrow_forwardxp x+xarrow_forward
- For the given graph, determine the following. -3 12 УА 4 3 - -1 ° 1 2 3 x -1. -2- a. Determine for which values of a the lim f (x) exists but f is not continuous at x = a. a b. Determine for which values of a the function is continuous but not differentiable at x = a. aarrow_forwardI write with prove one-to-one linear Sanction but not onto Lexample.) b) write with Prove on to linear function but not oh-to-on (example). c) write with prove example x=y St Xandy two linear space over Sielad F.arrow_forwardUse the following graph of ƒ (x) to evaluate ƒ' (−1) and ƒ' (2). y +10+ 9 8 7 6 5 4 3 2 1- -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 x 3 4 0 8 9 10 -2 3 -4 5 -6 -7 -8 -9 -10- f'(-1)= f' (2)arrow_forward
- Algebra: Structure And Method, Book 1AlgebraISBN:9780395977224Author:Richard G. Brown, Mary P. Dolciani, Robert H. Sorgenfrey, William L. ColePublisher:McDougal LittellAlgebra & Trigonometry with Analytic GeometryAlgebraISBN:9781133382119Author:SwokowskiPublisher:CengageGlencoe Algebra 1, Student Edition, 9780079039897...AlgebraISBN:9780079039897Author:CarterPublisher:McGraw Hill
- Big Ideas Math A Bridge To Success Algebra 1: Stu...AlgebraISBN:9781680331141Author:HOUGHTON MIFFLIN HARCOURTPublisher:Houghton Mifflin HarcourtCollege Algebra (MindTap Course List)AlgebraISBN:9781305652231Author:R. David Gustafson, Jeff HughesPublisher:Cengage Learning




