Algorithm for tree-like connections? : <p>The thing is I need to create an unidimensional array that represents a certain number of objects.
Those objects are organized as shown in the picture.
<a href="https://i.stack.imgur.com/sddQy.jpg" rel="nofollow noreferrer">Link</a></p>

<p>And I have to be able to tell wich one is conected to.
The number of objects is the only thing given.</p>

<p>Is there any algorithm of some sort to do this?</p>
