Saturday, May 15, 2010

Exercise from Fundamental's volume 2

Fundamental's second volume draft just reached 100 pages. I thought I'd mention an exercise from the book that I think it's quite nice. Suppose you concatenate a lot of strings with a stream. Of course, this is much more efficient than using straight string concatenation with messages like #,. But what is the efficiency of the stream method? Assume the strings are byte strings. If the resulting string has size k, what is the worst allocation scenario for the stream method expressed in terms of k? What is the best case scenario?

No comments: