Swipe to navigate through the chapters of this book
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.
Please log in to get access to this content
To get access to this content you need the following product:
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.
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.
An important part of this inductive hypothesis is that we can solve the problem no matter which corner is missing.
the show with zefrank, February 22, 2007.
Ever tried to search for recursion with Google? You might want to try it. And pay attention to the search suggestion.
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.
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.
If you’re using Python 2.6 or older, the result would be set([0, 2, 5]).
Inserting into or removing from the start of a list is a linear-time operation, remember? Generally not a good idea.
There are proverbs where this celebrity is replaced with a clown, a fool, or a monkey. Somewhat fitting, perhaps.
There is, in fact, a rich theory about random graphs. A web search should turn up lots of material.
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.
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.
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.
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.
The most important case in Chapter 11 is be when “easy” means polynomial. The logic applies in other cases too.
Only in DAGs, though. Finding longest paths in general graphs is an unsolved problem, as discussed in Chapter 11.
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.”
Discussed in the sidebar “Counting Sort & Fam,” earlier in this chapter.
- Induction and Recursion ... and Reduction
Magnus Lie Hetland
- Sequence number
- Chapter number
- Chapter 4