converts an array to a binary tree