JOIN
Get Time
forums   
Search | Watch Thread  |  My Post History  |  My Watches  |  User Settings
View: Flat (newest first)  | Threaded  | Tree
Previous Thread  |  Next Thread
Is it Wrong? | Reply
Process2:

if (A[M[i][j - 1]] < A[M[i + (1 << (j - 1))][j - 1]])
M[i][j] = M[i][j - 1];
else
M[i][j] = M[i + (1 << (j - 1))][j - 1];

may be should it:

if (A[M[i][j - 1]] < A[M[i + (1 << (j - 1))-1][j - 1]])
M[i][j] = M[i][j - 1];
else
M[i][j] = M[i + (1 << (j - 1))-1][j - 1];
Re: Is it Wrong? (response to post by FORHAD-SUST-BD) | Reply
I think the code is correct, while the recurrence is wrong:


M[i + 2^(j-1) - 1] should be M[i + 2^(j-1)]
Re: Is it Wrong? (response to post by chuchao333) | Reply
Yes, it seems the recurrence is wrong.
RSS