Page 120 of the programming pearl 1 version, M outside the N-integer population presents this algorithm to select equally potentially random elements.
InitToEmpty Size: = 0 while the size & lt; MTT: = RandInt (1, n) if not member (t) inserted (t) size: = size + 1 It has been said that the required number of member testing is low More than 2 M, unless M & L; N / 2
I want to know how to prove it, but my algorithm analysis background is failing me.
I understand that near MN will now take the program, because the result will have more elements in the set and the likelihood of the current RANDIT will be increased proportionally.
Can you help me find out this evidence?
I'm not a math magician, but I will give it a tough shot though it is not guaranteed to be true .
For each additional member of M, you choose a number, see if it is, and if it has been added. Otherwise, try it again until you are successful until you are trying something which is called a geometrical probability distribution.
So you are running M geometric tests. The value of each trial is expected 1 / p, therefore the expected 1 / p tries to get a number from the first in the M. P N is the number of numbers that we have already divided by M (ie how many inappropriate items / total goods). So for the fourth number, P = (N3) / N, which is likely to be an unused number, so the required number for the third number is N / N-3.
Expected price of run time has all been combined together. So something like that
e (run time) = N / N + N / (N -1) + N / (N -2) ... + N / (nm)
< P> Now if M & L; N / 2, then the last element of that closing is above 2. ((N / N / 2) == 2)) This is also clearly the biggest element in the whole conference. So if the biggest element selects two, and the summary of the M elements, then the whole run time is surrounded by EV 2M.Let me know that none of these is clear. Correct me if none of these is wrong :)
Comments
Post a Comment