Skip to main content

Divide, Combine, and Conquer

  • Chapter
  • First Online:
Python Algorithms
  • 14k Accesses

Abstract

■■■

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 79.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 99.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 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. 2.

    Described by Udi Manber in his Introduction to Algorithms (see “References” in Chapter 4).

  3. 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. 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. 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. 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. 7.

    Timsort is, in fact, also used in Java SE 7, for sorting arrays.

  8. 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. 9.

    You can find the actual C code at http://svn.python.org/projects/python/trunk/Objects/listobject.c .

  10. 10.

    See https://bitbucket.org/pypy/pypy/src/default/rpython/rlib/listsort.py .

  11. 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. 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. 13.

    Actually, the approximation isn’t asymptotic in nature. If you want the details, you’ll find them in any good mathematics reference.

  14. 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. 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. 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. 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

Authors

Rights and permissions

Reprints 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

Publish with us

Policies and ethics