Prove that all trees are bipartite

The basic idea is fine.

Pick a node $v$ of $T$ to be the root. Let $u$ be any node of $T$; since $T$ is a tree, there is a unique path $P_u$ from $v$ to $u$. (Why?) Let $f(u)$ be the length of $P_u$. Let $V_E$ be the set of nodes for which $f(u)$ is even, and let $V_O$ be the set of those for which $f(u)$ is odd. Finish by showing that every edge of $T$ has one endpoint in $V_E$ and the other in $V_O$.


You've pretty much got it. Perhaps an easier way to say what you've said is take a vertex $v_0$ and put it in set $A$. Take any vertex in the tree that is an even number of edges away and put it in $A$. Put the rest in $B$.

If two vertices $v_1, v_2$ in $A$ are connected by edge $e$ then we can make a loop with the path from $v_0$ to $v_1$, $v_0$ to $v_2$, and edge $e$. Then the original set we were pulling the vertices from is not a tree. Thus, doing the prior process for a tree results in no $2$ vertices in $A$ being connected. Similarly, this holds for $B$. Then we have shown that a tree is bipartite.


Your reasoning seems to be OK. Start from the root and write next to each vertex a number of how many edges you need to pass in order to reach it. At the end put the odd-numbered vertices in one set and the even-numbered in the other. Obviously two vertices from the same set aren't connected, as in a tree there's only one path from one vertex to another (Note that all neigbours from one vertex are of different parity, compared to it).

Actually it's well known that a graph is bipartite iff it contains no cycles of odd length. A tree contains no cycles at all, hence it's bipartite.