[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: not enough real programmers?
[followups set to afc].
Volker Hetzer <volker.hetzer@abg1.siemens.de> writes:
> Everett M. Greene wrote:
>
> > > 4. "Write a program to perform a "perfect shuffle" on an array of 52
> > > numbers."
> >
> > Anybody with a good answer to question 4 doesn't need to be interviewing
> > for a job. There are any number of companies, academic institutions,
> > etc. who would like a definitive answer to that problem.
> If perfect means "all permutations are equally likely", then Knuth has an answer.
> Without having read it, I'd simply use a random number generator to put cards
> from one array into the other (modulo the remaining cards, etc.). It should give
> a shuffle as good as the random number generator.
This isn't Knuth's answer, though. That solution is in-place and runs
in O(n), while your requires an extra array and O(n^2) time.
--
Ariel Scolnicov |"GCAAGAATTGAACTGTAG" |ariels@compugen.co.il
Compugen Ltd. |Tel: +972-2-6795059 (Jerusalem) \ NEW IMPROVED URL!
72 Pinhas Rosen St. |Tel: +972-3-7658520 (Main office)`--------------------
Tel-Aviv 69512, ISRAEL |Fax: +972-3-7658555 http://3w.compugen.co.il/~ariels
- References:
- Re: Byte Magazine: 18 Vintage issues, 1985-1986
- From: "Bob Headrick" <bobh@proaxis.com>
- Re: Byte Magazine: 18 Vintage issues, 1985-1986
- From: mzenier@netcom.com (Mark Zenier)
- Re: Byte Magazine: 18 Vintage issues, 1985-1986
- From: bill_h <bill_h@sunsouthwest.com>
- Re: Byte Magazine: 18 Vintage issues, 1985-1986
- From: Charles Richmond <richmond@plano.net>
- Re: Byte Magazine: 18 Vintage issues, 1985-1986
- From: jschmitz@qis.net (JoAnne Schmitz)
- Re: Byte Magazine: 18 Vintage issues, 1985-1986
- From: rmk@toad.rmkhome.com
- not enough real programmers? (was Re: Byte Magazine: 18 Vintage issues, 1985-1986)
- From: Eric Smith <eric-no-spam-for-me@brouhaha.com>
- Re: not enough real programmers? (was Re: Byte Magazine: 18 Vintage issues, 1985-1986)
- From: Charles Eicher <ceicher@inav.net>
- Re: not enough real programmers? (was Re: Byte Magazine: 18 Vintage issues, 1985-1986)
- From: brucehoult@pobox.com (Bruce Hoult)
- Re: not enough real programmers? (was Re: Byte Magazine: 18 Vintage issues, 1985-1986)
- From: hshubs@mindspring.com (Howard S Shubs)
- Re: not enough real programmers? (was Re: Byte Magazine: 18 Vintage issues, 1985-1986)
- From: "Ian St. John" <istjohn@spamcop.net>
- Re: not enough real programmers? (was Re: Byte Magazine: 18 Vintage issues, 1985-1986)
- From: prs@gol.com (Peter Stephenson)
- Re: not enough real programmers? (was Re: Byte Magazine: 18 Vintage issues, 1985-1986)
- From: gillies@cs.ubc.ca (Donald Gillies)
- Re: not enough real programmers?
- From: mojaveg@ridgecrest.ca.us (Everett M. Greene)
- Re: not enough real programmers?
- From: Volker Hetzer <volker.hetzer@abg1.siemens.de>