Given a tree (binary) structure, with depth N. Is it possible to compute some lookup index for mapping leaf nodes.
Each node knows its parent, and its childs(left and right) if its not a leaf.
My Idea was something like saying rootnode is index 0, then left:1,left:left:2, left:left:left:3, left:left:right:4, left:right:left:5,left:right:right:6,right:7,right:left:8 e.g.
So given a leaf node, how can i compute the index smartest.
Other solutions are accepted also, if its smarter to give the leafs indexes from 0,1...L, where L is the number of leafs.