Abstract
■■■
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Notes
- 1.
Note that some authors use the conquer term for the base case of the recursion, yielding the slightly different ordering: divide, conquer, and combine.
- 2.
Described by Udi Manber in his Introduction to Algorithms (see “References” in Chapter 4).
- 3.
For example, in the skyline problem, you would probably want to split the base case element (L,H,R) into two pairs, (L,H) and (R,H), so the combine function can build a sequence of points.
- 4.
Actually, more flexible may not be entirely correct. There are many objects (such as complex numbers) that can be hashed but that cannot be compared for size.
- 5.
In statistics, the median is also defined for sequences of even length. It is then the average of the two middle elements. That’s not an issue we worry about here.
- 6.
In theory, we could use the guaranteed linear version of select to find the median and use that as a pivot. That’s not something likely to happen in practice, though.
- 7.
Timsort is, in fact, also used in Java SE 7, for sorting arrays.
- 8.
See, for example, the file listsort.txt in the source code (or online, http://svn.python.org/projects/python/ trunk/Objects/listsort.txt).
- 9.
You can find the actual C code at http://svn.python.org/projects/python/trunk/Objects/listobject.c .
- 10.
- 11.
Real numbers usually aren’t all that arbitrary, of course. As long as your numbers use a fixed number of bits, you can use radix sort (mentioned in Chapter 4) and sort the values in linear time.
- 12.
I think that’s so cool, I wanted to add an exclamation mark after the sentence ... but I guess that might have been a bit confusing, given the subject matter.
- 13.
Actually, the approximation isn’t asymptotic in nature. If you want the details, you’ll find them in any good mathematics reference.
- 14.
A region is convex if you can draw a line between any two points inside it, and the line stays inside the region.
- 15.
I’m still assuming that we want a nonempty interval. If it turns out to have a negative sum, you could always use an empty interval instead.
- 16.
The AA-tree is, in a way, a version of the BB-tree, or the binary B-tree, which was introduced by Rudolph Bayer in 1971 as a binary representation of the 2-3-tree.
- 17.
It is quite common to call this operation build-heap and to reserve the name heapify for the operation that repairs a single node. Thus, build-heap runs heapify on all nodes but the leaves.
Author information
Authors and Affiliations
Rights and permissions
Copyright information
© 2014 Magnus Lie Hetland
About this chapter
Cite this chapter
Hetland, M.L. (2014). Divide, Combine, and Conquer. In: Python Algorithms. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-0055-1_6
Download citation
DOI: https://doi.org/10.1007/978-1-4842-0055-1_6
Published:
Publisher Name: Apress, Berkeley, CA
Print ISBN: 978-1-4842-0056-8
Online ISBN: 978-1-4842-0055-1
eBook Packages: Professional and Applied ComputingApress Access BooksProfessional and Applied Computing (R0)