
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 And Its Applications 7th Edition
- 1. Let W, U, and S be graphs defined as follows: • V(W) is the set of countries in the world; • V(U) is the set of countries in the European Union; V(S) is the set of countries in the Schengen Area; ● for X = {W,U,S}, E(X) is the set of pairs of countries in V(X) that share a land border. Recall that land borders between countries in the Schengen Area are special in that they can be crossed without a passport. (a) The notions of a country and a land border are somewhat ambiguous. Explain the notions you will use to get a precise definition of the graphs W, U, and S. (b) Is S a subgraph of U? Is U an induced subgraph of W? Justify your answers. (c) Using non-mathematical language, explain what it means for a country x if VEV(S) and dw (v) = 0. Give all such countries. Let A = {v Є V(W) \V(S) such that |Nw(v)| > 0 and Nw (v) ≤ V(S)}. (d) Using non-mathematical language, explain what the set A represents in terms of countries and land borders. Give a specific element of A or explain why A…arrow_forward3. A spreadsheet consists of cells indexed by a row and a column. Each cell contains either a value or a formula that depends on the values of other cells. (a) Describe a graph, digraph, or network that models an arbitrary spreadsheet and allows you to answer the remaining parts of this question. (b) Explain, by referring to the graph, digraph, or network, when it is possible to change the value of cell x without changing the value of cell y. (c) Explain, by referring to the graph, digraph, or network, when it is possible to calculate the values of all cells in the spreadsheet. Consider the following spreadsheet with 5 rows, 7 columns, and 35 cells. For exam- ple, cell el contains a value, whereas cell al contains a formula that depends on the values cells el and 95. a b с d e f g 1 el+g5 al-c5 110 al+cl 180 f5-el c1+c2 2 al+bl a2+c4 240 a2+c2 120 f5-e2 e3+e5 3 a2+b2 a3-c3 100 a3+c1 200 f5-e3 f1+f2 4 a3+b3 a4+c2 220 a4+c2 100 f5-e4 f3+f4 5 a4+b4 a5-c1 130 a5+c5 120 g3+g4 gl+g2 (d) Can…arrow_forwardt 56 65 33arrow_forward
- Solution: Solution: 7.2 2x²+5x-3. Diagram: till sh one The Steps the same technique as in 4 and 5) above to factor the following Show all the Steps. "Diagram, (2) 03) But (be Wha x+2 3arrow_forwardQ/ solving Laplace equation on Rectangular Rejon a xx+uyy = o u (x, 0) = u(x,2) = 0 u (o,y) = y (1,y) = 27arrow_forwardSolve the following equation forx. leave answer in Simplified radical form. 5x²-4x-3=6arrow_forward
- MATCHING LIST Question 6 Listen Use the given equations and their discriminants to match them to the type and number of solutions. 00 ed two irrational solutions a. x²+10x-2=-24 two rational solutions b. 8x²+11x-3=7 one rational solution c. 3x²+2x+7=2 two non-real solutions d. x²+12x+45 = 9 DELL FLOWER CHILD 10/20 All Changes S $681 22991arrow_forward88 MULTIPLE CHOICE Question 7 Listen The following irrational expression is given in unsimplified form with four op- tions in simplified form. Select the correct simplified form. Select only one option. A 2±3√√2 B 4±√3 2±√ √3 D 1±√√3 DELL FLOWER CHILD 11/200 4 ± √48 4 ✓ All Changes Saved 165arrow_forwardQ / solving ha place equation a x x + u y y = 0 u (x, 0)=0 u ( x, 2) = 10 u (o,y) = 4 (119)=0 и on Rectangular Rejonarrow_forward
- (a) Test the hypothesis. Consider the hypothesis test Ho = : against H₁o < 02. Suppose that the sample sizes aren₁ = 7 and n₂ = 13 and that $² = 22.4 and $22 = 28.2. Use α = 0.05. Ho is not ✓ rejected. 9-9 IV (b) Find a 95% confidence interval on of 102. Round your answer to two decimal places (e.g. 98.76).arrow_forwardLet us suppose we have some article reported on a study of potential sources of injury to equine veterinarians conducted at a university veterinary hospital. Forces on the hand were measured for several common activities that veterinarians engage in when examining or treating horses. We will consider the forces on the hands for two tasks, lifting and using ultrasound. Assume that both sample sizes are 6, the sample mean force for lifting was 6.2 pounds with standard deviation 1.5 pounds, and the sample mean force for using ultrasound was 6.4 pounds with standard deviation 0.3 pounds. Assume that the standard deviations are known. Suppose that you wanted to detect a true difference in mean force of 0.25 pounds on the hands for these two activities. Under the null hypothesis, 40 = 0. What level of type II error would you recommend here? Round your answer to four decimal places (e.g. 98.7654). Use a = 0.05. β = i What sample size would be required? Assume the sample sizes are to be equal.…arrow_forward= Consider the hypothesis test Ho: μ₁ = μ₂ against H₁ μ₁ μ2. Suppose that sample sizes are n₁ = 15 and n₂ = 15, that x1 = 4.7 and X2 = 7.8 and that s² = 4 and s² = 6.26. Assume that o and that the data are drawn from normal distributions. Use απ 0.05. (a) Test the hypothesis and find the P-value. (b) What is the power of the test in part (a) for a true difference in means of 3? (c) Assuming equal sample sizes, what sample size should be used to obtain ẞ = 0.05 if the true difference in means is - 2? Assume that α = 0.05. (a) The null hypothesis is 98.7654). rejected. The P-value is 0.0008 (b) The power is 0.94 . Round your answer to four decimal places (e.g. Round your answer to two decimal places (e.g. 98.76). (c) n₁ = n2 = 1 . Round your answer to the nearest integer.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




