Guest User

Untitled

a guest
Nov 16th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. function FindNext(T, x).
  2. if x < T.min then
  3. return T.min
  4. if x ≥ T.max then // no next element
  5. return M
  6. i = floor(x/√M)
  7. lo = x mod √M
  8. hi = x − lo
  9. if lo < T.children[i].max then
  10. return hi + FindNext(T.children[i], lo)
  11. return hi + T.children[FindNext(T.aux, i)].min
  12. end
  13.  
  14. y = FindNext(T.aux, i)
  15. return y√M + T.children[y].min
Add Comment
Please, Sign In to add comment