So the most natural approach that we use very often,
particularly when talking about sorting and searching algorithms,
is to, well first of all, the y coordinate is easy.
That's just, well it's the depth, but since they go down,
it's the height minus the depth.
So we start with the root at the highest and then just subtract one.
So we know the y-coordinate of every node.
The x-coordinate of the node, the easiest way to
set that up is to just do a recursive inorder traversal of the tree.
And just assign x coordinates every time you reach a note.
And that's corresponding to say the recursive
programming says what's a coordinate of a root?
It's the number of nodes on the left plus 1 and
then the x coordinate of everything on the right side is bigger than that.
Then you can see immediately that number one is easy to assign the coordinates,
just do an in order a traversal of the tree and
number two it's basis the nodes on the tree out nicely.
Usually when we draw big trees, we leave big binary trees,
we leave out the external nodes.
Now, there's a problem with this, is that you get the distracting long edges for
some kinds of trees.
Particularly, for say binary trees will represent general trees,
and You can use a similar algorithm like this for general trees, by the way.
But anyway, that's a problem.
So what we do sometimes is, take the x coordinate and
at every level, we just evenly space the nodes.
If there's four nodes at that level, we evenly space them and
center them on the root node.