Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fun log(base: Double, n: Double) = Math.log(n) / Math.log(base)
- val fullHeight = Math.round(log(2.0, size.toDouble())).toInt() + 1
- val level = Math.floor(log(2.0, vertex.toDouble())).toInt() + 1
- val height = fullHeight - level
- val nodeNum = vertex - Math.pow(2.0, level.toDouble() - 1).toInt() + 1
- val leaves = Math.pow(2.0, height.toDouble()).toInt()
- val segment = leaves * (nodeNum - 1) to leaves * (nodeNum) - 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement