I have this requirement to create a tree like structure. Each parent can have at most 3 children. And the tree grows 15 level deep (total 3^15 members). The thing is, addition of child nodes are done by giving each parent a child. For example
1
2 3 4
5 8 11 6 9 12 7 10 13
Tree grows like this. 5th child goes under 2, 6th child goes under 3, 7th child goes under 4, 8 again under 2... etc. I am given the root node and member to be added, for example, 1 and 10. How can I programmatically find which position the new child should be added?. An answer with an algorithm would be much helpful
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…