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 freeUse the divide-and-conquer approach to write an algorithm that finds the largest item in a list of \(n\) items. Analyze your algorithm, and show the results in order notation.
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).
Write for the following problem a recursive algorithm whose worst-case time complexity is not worse than \(\Theta(n \lg n)\). Given a list of \(n\) distinct positive integers, partition the list into two sublists, cach of size \(n / 2,\) such that the difference between the sums of the integers in the two sublists is maximized. You may assume that \(n\) is a multiple of 2.
How many multiplications would be performed in finding the product of two \(64 \times 64\) matrices using Strassen's Method (Algorithm 2.8)?
Write a nonrecursive algorithm for Quicksort (Algorithm 2.6). Analyze your algorithm, and give the results using order notation.
What do you think about this solution?
We value your feedback to improve our textbook solutions.