I'm sorry if this is the wrong one, was unsure if this was computer science, programming, or mathematics related. I'm going with mathematics because it is semi-graph theory related.
I have a tree with n-child nodes attached to each parent, and I know the indices of each node. Would the appropriate way to determine the parent be
i is the index of the new node being added, one to handle the offset of starting at 0 as the root, and
n being the number of children allowed per parent.
I know that this holds true for n=2, and from testing it works for n=3, and n=4, but I would like to make absolute certain that it is correct.