Chapter 2: Problem 42
Use the divide-and-conquer approach to write a recursive algorithm that finds the maximum sum in any contiguous sublist of a given list of \(n\) real values. Analyze your algorithm, and show the results in order notation.
Chapter 2: Problem 42
Use the divide-and-conquer approach to write a recursive algorithm that finds the maximum sum in any contiguous sublist of a given list of \(n\) real values. Analyze your algorithm, and show the results in order notation.
All the tools & learning materials you need for study success - in one app.
Get started for freeShow that the recurrence equation for the worst-case time complexity for Mergesort (Algorithms \(2.2 \text { and } 2.4)\) is given by \\[ W(n)=W\left(\left[\frac{n}{2}\right\rfloor\right)+W\left(\left\lceil\frac{n}{2}\right]\right)+n-1 \\] when \(n\) is not restricted to being a power of 2
Suppose that, in a divide-and-conquer algorithm, we always divide an in stance of size \(n\) of a problem into \(n\) subinstances of size \(n / 3,\) and the dividing and combining steps take lincar time. Write a recurrence equation for the running time \(T(n),\) and solve this recurrence equation for \(T(n) .\) Show your solution in order notation.
How many multiplications would be performed in finding the product of two \(64 \times 64\) matrices using Strassen's Method (Algorithm 2.8)?
Write algorithms that perform the operations \(u \times 10^{m}\) \(u\) divide \(10^{n}\) \(u\) rem \(10 "\) where \(u\) represents a large integer, \(m\) is a nonnegative integer, divide returns the quotient in integer division, and rem returns the remainder. Analyze your algorithms, and show that these operations can be done in linear time.
Write a divide-and-conquer algorithm for the Towers of Hanoi Problem. The Towers of Hanoi Problem consists of three pegs and \(n\) disks of different sizes. The object is to move the disks that are stacked, in decreasing order of their size, on one of the three pegs to a new peg using the third one as a temporary peg. The problem should be solved according to the following rules: (1) when a disk is moved, it must be placed on one of the three pegs: (2) only one disk may be moved at a time, and it must be the top disk on one of the pegs; and (3) a larger disk may never be placed on top of a smaller disk. (a) Show for your algorithm that \(S(n)=2^{n}-1 .\) [Here \(S(n)\) denotes the number of steps (moves), given an input of \(n\) disks. (b) Prove that any other algorithm takes at least as many moves as given in part (a).
What do you think about this solution?
We value your feedback to improve our textbook solutions.