Advertisement
Guest User

Untitled

a guest
Apr 18th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 0.47 KB | None | 0 0
  1.         fun log(base: Double, n: Double) = Math.log(n) / Math.log(base)
  2.  
  3.         val fullHeight = Math.round(log(2.0, size.toDouble())).toInt() + 1
  4.         val level = Math.floor(log(2.0, vertex.toDouble())).toInt() + 1
  5.         val height = fullHeight - level
  6.         val nodeNum = vertex - Math.pow(2.0, level.toDouble() - 1).toInt() + 1
  7.         val leaves = Math.pow(2.0, height.toDouble()).toInt()
  8.  
  9.         val segment = leaves * (nodeNum - 1) to leaves * (nodeNum) - 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement