   generating a random tree, my algorithm isn't correct?
  I came up with a very simple algorithm for generating a tree for testing a particular problem I'm working on.  However one of my friends claims my algorithm is incorrect and will create loopbacks.  I however do not see this and would like a third opinion.Its pretty simple, I start with a single root node(1) and do the following:for(int j = 2, 3, ..., N)   i = random(1 to j - 1)   create edge(i, j)That's it.  So when j = 2, i can only go from 1 to j - 1, and hence i only equals 1.  So in my adjacency matrix, I set edge(1,2), which means root node has the new node(2) as a child.  And this continues for N nodes.Does anybody see a problem with this?   
  No, that looks fine WRT cycles. I'm not sure about the statistical properties of the generated tree, and it looks as though average branching factors will differ between levels. Is this a problem?   ;  No, it doesn't matter if node levels are even or not.  I was just told something was wrong with it and I don't see ANYTHING programatically or functionally wrong with it.   ;  Simple proof: each node except the root (the first) will have exactly one incoming edge, and cycles are impossible because each edge always goes from a node of a lower number to a node with a greater number. Therefore this algorithm creates a tree.   