Chapter 2: Problem 7
Use 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.
/*! This file is auto-generated */ .wp-block-button__link{color:#fff;background-color:#32373c;border-radius:9999px;box-shadow:none;text-decoration:none;padding:calc(.667em + 2px) calc(1.333em + 2px);font-size:1.125em}.wp-block-file__button{background:#32373c;color:#fff;text-decoration:none}
Learning Materials
Features
Discover
Chapter 2: Problem 7
Use 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.
All the tools & learning materials you need for study success - in one app.
Get started for free
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.
Use Binary Search (Algorithm 2.1 ) to search for the integer 120 in the following list (array) of integers. Show the actions step by step. $$\begin{array}{lllllllll} 12 & 34 & 37 & 45 & 57 & 82 & 99 & 120 & 134 \end{array}$$
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.
Assuming that Quicksort uses the first item in the list as the pivot item: (a) Give a list of \(n\) items (for example, an array of 10 integers) representing the worst-case scenario. (b) Give a list of \(n\) items (for example, an array of 10 integers) representing the best-case scenario.
Consider procedure solve \((P, I, O)\) given below. This algorithm solves problem \(P\) by finding the output (solution) \(O\) corresponding to any input \(l\) Assume \(g(n)\) basic operations for partitioning and combining and no basic operations for an instance of size 1 (a) Write a recurrence equation \(T(n)\) for the number of basic operations needed to solve \(P\) when the input size is \(n\) (b) What is the solution to this recurrence equation if \(g(n) \in \Theta(n)\) (proof not required \() ?\) (c) Assuming that \(g(n)=n^{2},\) solve the recurrence equation exactly for \(n=\) 27 (d) Find the general solution for \(n\) a power of 3
What do you think about this solution?
We value your feedback to improve our textbook solutions.