2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
|
|
@ -1,9 +1,12 @@
|
|||
Let <code>f</code> be a uniformly-randomly chosen mapping from the numbers 1..N to the numbers 1..N (note: not necessarily a permutation of 1..N; the mapping could produce a number in more than one way or not at all). At some point, the sequence <code>1, f(1), f(f(1))...</code> will contain a <em>repetition</em>, a number that occurring for the second time in the sequence.
|
||||
|
||||
|
||||
;Task:
|
||||
Write a program or a script that estimates, for each <code>N</code>, the average length until the first such repetition.
|
||||
|
||||
Also calculate this expected length using an analytical formula, and optionally compare the simulated result with the theoretical one.
|
||||
|
||||
|
||||
This problem comes from the end of Donald Knuth's [http://www.youtube.com/watch?v=cI6tt9QfRdo Christmas tree lecture 2011].
|
||||
|
||||
Example of expected output:
|
||||
|
|
@ -30,3 +33,4 @@ Example of expected output:
|
|||
18 4.9951 5.0071 ( 0.24%)
|
||||
19 5.1312 5.1522 ( 0.41%)
|
||||
20 5.2699 5.2936 ( 0.45%)</pre>
|
||||
<br>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue