use array as memory for tree