diff --git a/GA3/ga3.pdf b/GA3/ga3.pdf index 183c031..a186554 100644 Binary files a/GA3/ga3.pdf and b/GA3/ga3.pdf differ diff --git a/GA3/ga3.tex b/GA3/ga3.tex index 3f06aaa..2fa6e30 100644 --- a/GA3/ga3.tex +++ b/GA3/ga3.tex @@ -639,7 +639,7 @@ FUNCTION JOIN-INTERVALS(X) c $\gets$ 1 n $\gets$ 0 - start $\gets$ X[i][1] + start $\gets$ X[1][1] for i from 2 to X.length: c $\gets$ c + X[i][2] if c == 0: @@ -654,4 +654,11 @@ FUNCTION JOIN-INTERVALS(X) The complexity of this algorithm is $O(n\log(n))$ since the sorting is in $\Theta(n\log(n))$ and the union operation afterwards is $\Theta(n)$. +\section{Bonus} + +The number of possible trees with $n$ nodes can be defined recursively. The number of trees with 0 or 1 node is clearly 1, since there is no freedom in arranging any remaining elements as children. For $n$ nodes, this number can be defined as the the sum, for each $x, y \in N_0$ s.t. $x + y = n - 1$, of the number of trees with $x$ nodes times the number of trees with $y$ nodes. We consider only $n - 1$ nodes since one node must be the root of the tree. +Using math notation, the number $T_n$ of trees with $n$ nodes can be expressed as: + +$$T_n = 1 \hspace{1cm} n = 0 \lor n = 1$$ +$$T_n = \sum_{i = 0}^{n-1} C_i C_{n-1-i} \hspace{1cm} n \geq 2$$ \end{document} \ No newline at end of file