small change here
x =  n-pow(2,floor(log(n)));
pos = (x*k)%n+1;

surender

On Fri, Jul 22, 2011 at 4:54 PM, surender sanke <[email protected]> wrote:

> here's O(1)
> x =  n-pow(2,floor(log2(n)));
> pos = x*k+1;
>
> surender
> On Fri, Jul 22, 2011 at 1:19 PM, Interstellar Overdrive <
> [email protected]> wrote:
>
>> Yes, the solution with Circular linked list works fine but it certainly
>> involves great space considerations. I guess solving Josephus problem using
>> dynamic programming more apt. It's O(n) as well.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msg/algogeeks/-/R6u41EDvGlcJ.
>>
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to