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 MATHEMATICS LOOSELEAF W/CONNECT
- A smallish urn contains 16 small plastic bunnies - 9 of which are pink and 7 of which are white. 10 bunnies are drawn from the urn at random with replacement, and X is the number of pink bunnies that are drawn. (a) P(X=6)[Select] (b) P(X>7) ≈ [Select]arrow_forward. Find how many years it takes for $1786 to grow to $2063 if invested at 2.6% annual interest compounded monthly. 12+arrow_forwardK=3, Gauss Seidel Fill in only 4 decimal places here in Canvas. Make sure in exam and homework, 6 decimal places are required. X1 = X2 = X3 =arrow_forward
- A smallish urn contains 25 small plastic bunnies - 7 of which are pink and 18 of which are white. 10 bunnies are drawn from the urn at random with replacement, and X is the number of pink bunnies that are drawn. (a) P(X = 5)=[Select] (b) P(X<6) [Select]arrow_forwardThe fox population in a certain region has an annual growth rate of 8 percent per year. It is estimated that the population in the year 2000 was 22600. (a) Find a function that models the population t years after 2000 (t = 0 for 2000). Your answer is P(t) = (b) Use the function from part (a) to estimate the fox population in the year 2008. Your answer is (the answer should be an integer)arrow_forwardrarrow_forward
- The solutions are 1 where x1 x2- ● Question 11 Solve: x 54 Give your answer as an interval. Question 12arrow_forwardA population of deer in Pierce County currently has 1875 deer, but due to urban development, the population is decreasing at a rate of 1.1% a year. a) Assuming this growth rate continues, find the formula for a function f(t) describing this population. b) In how many years will the population reach 1300? Do the problems on your own paper, show all your work, and submit your scanned work below. Choose File No file chosenarrow_forward● Question 7 Solve the equation. log2(3m - 5) = log2(m +8) m n = Question 8arrow_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




