[comp.sources.wanted] Programming Pearls

mason@tmsoft.uucp (Dave Mason) (05/20/89)

In article <11998@grebyn.COM> scotth@grebyn (Scott Hutchinson) writes:
>In article <3008@cps3xx.UUCP> reedp@frith.egr.msu.edu () writes:
>>The problem is that as the list fills up with numbers, the time spent in
>>the do loop getting a number not already in the list grows very large.
>
>	How about filling the array initially with the numbers in order,
>then just doing random swaps.  like:

This gives me a chance to point out a wonderful book:
	Programming Pearls, Jon Bentley, Addison-Wesley, 1986

There is a complete discussion of this problem starting on page 117.
The solution suggested by Scott (and numerous others) is fairly good,
(and the first one covered in the book) but Bentley examines the
spectrum of related problems.

Every programmer should own this book and read it at least once/year.
I have made it the text in a course (where there wasn't an obvious
text) purely because I felt all the students should own it!
	../Dave