Chapter 0: Q7E (page 11)
How long does the recursive multiplication algorithm (page 25) take to multiply an n -bit number by an m -bit number? Justify your answer.
Short Answer
The recursive multiplication algorithm takes time.
Chapter 0: Q7E (page 11)
How long does the recursive multiplication algorithm (page 25) take to multiply an n -bit number by an m -bit number? Justify your answer.
The recursive multiplication algorithm takes time.
All the tools & learning materials you need for study success - in one app.
Get started for freeThe tramp steamer problem. You are the owner of a steamship that can apply between a group of port cities V . You make money at each port: a visit to city i earns you a profit of dollars. Meanwhile, the transportation cost from port i to port j is .You want to find a cyclic route in which the ratio of profit to cost is maximized.
To this end, consider a directed graph whose nodes are ports, and which has edges between each pair of ports. For any cycle C in this graph, the profit-to-cost ratio is
role="math" localid="1658920675878"
Let r' be the maximum ratio achievable by a simple cycle. One way to determine r' is by binary search: by first guessing some ratio r , and then testing whether it is too large or too small. Consider any positive . Give each edge a weight of .
The SPANNING TREE problem is the following.Input: An undirected graph Output: A spanning tree of in which each node has degree , if such a tree exists.Show that for any :
Mean and median. One of the most basic tasks in statistics is to summarize a set of observations by a single number. Two popular choices for this summary statistic are:
• The median, which we’ll call
• The mean, which we’ll call
(a) Show that the median is the value of that minimizes the function
You can assume for simplicity that is odd. (Hint: Show that for any , the function decreases if you move either slightly to the left or slightly to the right.)
(b) Show that the mean is the value of that minimizes the function
One way to do this is by calculus. Another method is to prove that for any ,
Notice how the function for penalizes points that are far from much more heavily than the function for . Thus tries much harder to be close to all the observations. This might sound like a good thing at some level, but it is statistically undesirable because just a few outliers can severely throw off the estimate of . It is therefore sometimes said that is a more robust estimator than . Worse than either of them, however, is , the value of that minimizes the function
(c) Show that can be computed in O(n) time (assuming the numbers are small enough that basic arithmetic operations on them take unit time).
Show that any array of integers can be sorted in O (n + M) time, where
role="math" localid="1659938331794"
For small M, this is linear time: why doesn’t the lower bound apply in this case?
Question: An Eulerian tourin an undirected graph is a cycle that is allowed to pass through each vertex multiple times, but must use each edge exactly once.
This simple concept was used by Euler in to solve the famous Konigsberg bridge problem, which launched the field of graph theory. The city of Konigsberg (now called Kaliningrad, in western Russia) is the meeting point of two rivers with a small island in the middle. There are seven bridges across the rivers, and a popular recreational question of the time was to determine whether it is possible to perform a tour in which each bridge is crossed exactly once. Euler formulated the relevant information as a graph with four nodes (denoting land masses) and seven edges (denoting bridges), as shown here.
Notice an unusual feature of this problem: multiple edges between certain pairs of nodes.
(a) Show that an undirected graph has an Eulerian tour if and only if all its vertices have even degree. Conclude that there is no Eulerian tour of the Konigsberg bridges.
(b) An Eulerian pathis a path which uses each edge exactly once. Can you give a similar if-and-only-if characterization of which undirected graphs have Eulerian paths?
(c) Can you give an analog of part (a) for directedgraphs?
What do you think about this solution?
We value your feedback to improve our textbook solutions.