Skip to main content

Induction and Recursion ... and Reduction

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

Abstract

You must never think of the whole street at once, understand? You must only concentrate on the next step, the next breath, the next stroke of the broom, and the next, and the next. Nothing else.

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.

    This is actually Exercise 2-10, but you can still have a go at that, if you want. Try to solve it without using induction.

  2. 2.

    Actually, the solution idea presented in the following will work for a checkerboard where an arbitrary square is missing. I recommend you verify that for yourself.

  3. 3.

    An important part of this inductive hypothesis is that we can solve the problem no matter which corner is missing.

  4. 4.

    the show with zefrank, February 22, 2007.

  5. 5.

    Ever tried to search for recursion with Google? You might want to try it. And pay attention to the search suggestion.

  6. 6.

    As mentioned in Chapter 3, in weak induction the induction hypothesis applies to n–1, while in strong induction it applies to all positive integers k < n.

  7. 7.

    These algorithms aren’t all that useful, but they’re commonly taught, because they serve as excellent examples. Also, they’re classics, so any algorist should know how they work.

  8. 8.

    If you’re using Python 2.6 or older, the result would be set([0, 2, 5]).

  9. 9.

    Inserting into or removing from the start of a list is a linear-time operation, remember? Generally not a good idea.

  10. 10.

    There are proverbs where this celebrity is replaced with a clown, a fool, or a monkey. Somewhat fitting, perhaps.

  11. 11.

    There is, in fact, a rich theory about random graphs. A web search should turn up lots of material.

  12. 12.

    The description “detect when some dependency is missing, download and install it” is, in fact, almost a literal description of another algorithm topological sorting, which is discussed in Chapter 5.

  13. 13.

    Without effective selection, we’re not gaining anything. For example, the algorithms I’ve compared with, insertion and selection sort, are both quadratic, because selecting the largest or smallest element among unsorted elements isn’t any easier than inserting it among sorted ones.

  14. 14.

    In general, you should, of course, be careful about making unwarranted assumptions. In the words of Alec Mackenzie (as quoted by Brian Tracy), “Errant assumptions lie at the root of every failure.” Or, as most people would put it, “Assumption is the mother of all f@#k-ups.” Assumptions in induction are proven, though, step by step, from the base case.

  15. 15.

    Even though showing termination is usually easy, the general problem is, in fact, not (algorithmically) solvable. See the discussion of the halting problem in Chapter 11 for details.

  16. 16.

    The most important case in Chapter 11 is be when “easy” means polynomial. The logic applies in other cases too.

  17. 17.

    Only in DAGs, though. Finding longest paths in general graphs is an unsolved problem, as discussed in Chapter 11.

  18. 18.

    As you may recall, the contrapositive of “If X, then Y” is “If not Y, then not X,” and these statements are equivalent. For example, “I think, therefore I am” is equivalent to “I am not, therefore I think not.” However, it is not equivalent to “I am, therefore I think.”

  19. 19.

    Discussed in the sidebar “Counting Sort & Fam,” earlier in this chapter.

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). Induction and Recursion ... and Reduction. In: Python Algorithms. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-0055-1_4

Download citation

Publish with us

Policies and ethics