There are a few ways to represent a tree T with n nodes.
One particularly flexible way is in terms of three arrays. For :
How can we test if node i is a leaf?