Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function FindNext(T, x).
- if x < T.min then
- return T.min
- if x ≥ T.max then // no next element
- return M
- i = floor(x/√M)
- lo = x mod √M
- hi = x − lo
- if lo < T.children[i].max then
- return hi + FindNext(T.children[i], lo)
- return hi + T.children[FindNext(T.aux, i)].min
- end
- y = FindNext(T.aux, i)
- return y√M + T.children[y].min
Add Comment
Please, Sign In to add comment