Fixed GA3 again and again and again

This commit is contained in:
Claudio Maggioni 2019-05-14 08:57:03 +02:00
parent 59b66ac061
commit d593dc5e17
2 changed files with 21 additions and 14 deletions

Binary file not shown.

View file

@ -222,7 +222,8 @@ Delete 12:
\end{verbatim}
}
The following printout was obtained by running the following BST implementation.with the following command:
The following printout was obtained by running the following BST implementation.
with the following command:
\begin{verbatim}
./tree.py 12 6 1 7 4 11 15 9 5 13 8 14 3 10 2 \| 6 2 12
@ -651,14 +652,20 @@ FUNCTION JOIN-INTERVALS(X)
X.length $\gets$ 2 * n
\end{lstlisting}
%
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)$.
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:
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$$
$$T_n = \sum_{i = 0}^{n-1} T_i T_{n-1-i} \hspace{1cm} n \geq 2$$
\end{document}