Currently I’m representing a binary tree in the following manner:
[None,2,[None,3,None]]
The tree above is rooted at 2. None means that the branch is empty.
I’d rather implement this in a list.
Are there better ways to do this (without resorting to creating classes) ?
It is possible to represent a binary tree using a flat list, as described here. How wasteful this method is would depend on the shape of your tree.
I am curious as to why you insist on avoiding classes. If you were to wrap this in a class, you could define a clean API and hide the details of your implementation from the eventual user.