tree-balancing

How to balance binary tree in PHP without rotating parent?

I will try to make myself as clear as possible. Based from Adjacency List Model: http://articles.sitepoint.com/article/hierarchical-data-database I need a way to balance this tree 0 / \ 1 2 / / \ 3 4 5 \ \ 6 7 to something like: 0 / \ 1 2 / \ / \ 3 ...

balancing a spanning tree of a growing undirected graph

I am looking for ways to maintain a relatively balanced spanning tree of a graph, as I add new nodes/edges to the graph. I have an undirected graph that starts as a single node, the "root". At each step, I add to the graph either a "cross edge" or a "parent-child edge". Cross edges introduce no new nodes; they just connect two existin...