Live data from Hacker News

Questions for Donald Knuth

informit.com

51–60 of 61 posts

Re: Questions for Donald Knuth

#51

I found the reply to Robert Tarjan interesting, and I wonder how many people who conduct programmer job interviews would have guessed that the Big O derived value vs the actual performance of the algorithm would be so unpredictable! "Another issue, when we come down to earth, is the efficiency of algorithms on real computers. As part of the Stanford GraphBase project I implemented four algorithms to compute minimum s…

I think the situation may have been like this:

Algorithm A has complexity like AO(n) and algorithm B goes like BO(n^2) (just made-up examples). So one would say that A is better. But the constant A happens to be very large, so that, until n becomes very large, B is actually faster, because the constant B is so much smaller. So conventional analysis would say that A is better in general, but its actual poor performance is "hiding" in the huge constant A, and is worse than B in real situations, where n never gets huge enough for A's complexity advantage to become relevant.

Re: Questions for Donald Knuth

#52

In the Q&A Knuth mentions TAOCP conversion to ebook several times - I did a quick search and found only millions of pirate sites. Does anyone know the legitimate source where the ebook can be bought? Informit seemed likely but there are only two digital volumes available there. (edit: there is a note saying "as they become available". I guess TAOCP is only partially portable so far, more to come.) (brag: I got a deci…

The ebooks for volumes 1 and 2 are available on InformIT. Volume 3 is coming later this summer and volume 4 will be available in the fall. informit.com/knuth is up to date.

Re: Questions for Donald Knuth

#53

The unpopularity and inherent goofiness of literate programming, and the way Knuth always mentions it in interviews, feels like a sort of elephant in the room whenever a new interview appears.

It's not popular, but I don't see it as at all goofy. When I have a well-defined but difficult segment of an application to write, I whip out my literate-programming tools so I can get it right the first time, document the heck out of it, and be able to get back into its complexity if I ever need to change it. It's a fabulous, almost magically successful technique, even if I don't use it for most of the code I write.

I think of it as analogous in feeling and usage to how a musician practices a difficult passage slowly, with a metronome, perfecting it at gradually increasing speeds until they can play it perfectly at speed. It's tedious and time-consuming, so I tend only to use it when I feel the need, but when I do, I'm glad it's there.

Re: Questions for Donald Knuth

#54
post #26

Given the facts that functional programming has been all the rage lately, and that advocates of functional programming tend to emphasize its mathematical roots, I would find it interesting to get Donald Knuth's take on the subject. Web search came up empty for me. Does anybody know of any statements he's made on functional programming?

He famously defended the GOTO statement and mostly writes programs in MIX assembly or Pascal. He seems pretty old school when it comes to programming.

Re: Questions for Donald Knuth

#55

I found the reply to Robert Tarjan interesting, and I wonder how many people who conduct programmer job interviews would have guessed that the Big O derived value vs the actual performance of the algorithm would be so unpredictable! "Another issue, when we come down to earth, is the efficiency of algorithms on real computers. As part of the Stanford GraphBase project I implemented four algorithms to compute minimum s…

Radix sort, its runtime is O(d * n) where d is the number of digits and n is the number of numbers being sorted. So for practical purposes d could become a constant in a given implementation. Compare that to other efficient algorithms (like merge sort) that are O(n log(n)). The constant could, below a certain input size, be larger than log(n).

Re: Questions for Donald Knuth

#56
The paragraph that jumped out at me:

"My work on introduced me to applications where 'correctness' cannot be defined. How do I know, for example, that my program for the letter A produces a correct image? I never will; and I've learned to live with that uncertainty. On the other hand, when I implemented the routines that interpret specifications and draw the associated bitmaps, there was plenty of room for rigor. The algorithms that go into font rendering are among the most interesting I've ever seen."

Re: Questions for Donald Knuth

#57

I found the reply to Robert Tarjan interesting, and I wonder how many people who conduct programmer job interviews would have guessed that the Big O derived value vs the actual performance of the algorithm would be so unpredictable! "Another issue, when we come down to earth, is the efficiency of algorithms on real computers. As part of the Stanford GraphBase project I implemented four algorithms to compute minimum s…

Jon Bentley (I think) described one situation once, where the problem was swapping two substrings in a string (again, I think). One of the algorithms was the double reversal trick[1] and the other wasn't; both were O(n). He implemented both and ran them on a large string on his (small) machine. One program finished in seconds while the other he terminated after several minutes.

The difference was that the string was large enough to force the machine to swap memory out to disk and the slow version was exactly pessimal regarding the machine's paging algorithm. It would touch a location on a page, forcing it to be brought back into memory, and then wouldn't touch the page again until it had touched all of the other pages of the string. The fast program did a lot of work on one page before going to the next and finished relatively quickly, the slow program thrashed. The same thing can be seen with modern machines' memory caching.

However, this kind of complexity analysis is intended to abstract over machine specific details like cache line sizes and paging algorithms, to let algorithms be compared in the abstract. Usually, if you don't trip over weird edge cases and if the problem is large enough (an assumption that is part of the analysis), an algorithm with a better O notation will kind, sorta, maybe always be faster than one with a worse.

(I think you have a misapprehension: the "large constant factor" is part of the simplification process from the hairy formula that actually describes an algorithms' performance (see Knuth's discussion of a "recurrence relation") to the abstract summary of Big-O: O(f) = n, O(g) = n^2,.... It is not any factor in the program itself. For example, O(f) = n is true if f(x) = x and if f(x) = 2x. But the second one will be slower.)

[1] https://tecnocode.co.uk/2008/11/19/string-swap-algorithms/

Re: Questions for Donald Knuth

#58
I'm picturing this as all of them sitting around a big table in a hotel bar, chatting while the writer records their questions and answers.

Andrew Binstock, Dr. Dobb's suddenly asks, "At the ACM Turing Centennial in 2012, you stated that you were becoming convinced that P = N P. Would you be kind enough to explain your current thinking on this question, how you came to it, and whether this growing conviction came as a surprise to you?"

Don Knuth replies, "As you say, I've come to believe that P = N P, namely that there does exist an integer M and an algorithm that will solve every n-bit problem belonging to the class N P in nM elementary steps...."

Scott Aaronson, MIT immediately has an aneurysm and after all of the convulsions and frothing is over, when the EMT's leave, they prop him back up in his chair and he only has the wherewithal to ask, "Would you recommend to other scientists to abandon the use of email, as you have done?"

Re: Questions for Donald Knuth

#60

The unpopularity and inherent goofiness of literate programming, and the way Knuth always mentions it in interviews, feels like a sort of elephant in the room whenever a new interview appears.

There are two aspects to Knuth-style literate programming:

(1) the primary emphasis is on the description and commentary rather than on the code;

(2) the order of presentation is determined by the description rather than the program.

The first is a useful and valuable tool. The second is an artefact of using a language like Pascal which has a strict inflexible order to its code and no suppor for modules. If you have a decent language then literate programming is just a different kind of comment syntax.

http://www.haskell.org/haskellwiki/Literate_programming

Post reply on HN