sorting - Bogosort optimization, probability related -


i'm coding question on online judge practice . question regarding optimizing bogosort , involves not shuffling entire number range every time. if after last shuffle several first elements end in right places fix them , don't shuffle elements furthermore. same last elements if in right places. example, if initial sequence (3, 5, 1, 6, 4, 2) , after 1 shuffle johnny gets (1, 2, 5, 4, 3, 6) fix 1, 2 , 6 , proceed sorting (5, 4, 3) using same algorithm. each test case output expected amount of shuffles needed improved algorithm sort sequence of first n natural numbers in form of irreducible fractions.

a sample input/output says n=6, answer 1826/189.

i don't quite understand how answer arrived at.

this looks similar 2011 google code jam, preliminary round, problem 4, answer n, don't know how 1826/189.


Comments

Popular posts from this blog

Delphi Wmi Query on a Remote Machine -