JOIN
 Select a Forum     Round Tables New Member Discussions News Discussions Algorithm Matches Marathon Matches NASA Tournament Lab TopCoder Cookbook High School Matches Sponsor Discussions Development Forums Design Forums Search | Watch Thread  |  My Post History  |  My Watches  |  User Settings View: Flat  | Threaded  | Tree Previous Thread  |  Next Thread Forums Tutorial Discussions Range Minimum Query and Lowest Common Ancestor Is it Wrong?
 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.
 Forums Tutorial Discussions Range Minimum Query and Lowest Common Ancestor Is it Wrong? Previous Thread  |  Next Thread