On Wednesday, 14 October 2015 at 14:42:31 UTC, Namal wrote:
Hello,

I don't remember exactly but I think when I first saw D code there was tree datatype implemented without pointers. Is it possible to make a tree struct without pointers?

If it is a binary tree, sure: just put your elements in an array and state that the left child of element at index i is the element at index 2i+1, and
that its right child is at index 2i+2

For example this tree:

            1
           / \
          2   3
         / \ / \
        4  5 6  7

Will be represented by this array: [1, 2, 3, 4, 5, 6, 7]

Reply via email to