Fixed GA3 again and again and again
This commit is contained in:
parent
59b66ac061
commit
d593dc5e17
2 changed files with 21 additions and 14 deletions
BIN
GA3/ga3.pdf
BIN
GA3/ga3.pdf
Binary file not shown.
19
GA3/ga3.tex
19
GA3/ga3.tex
|
@ -222,7 +222,8 @@ Delete 12:
|
||||||
\end{verbatim}
|
\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}
|
\begin{verbatim}
|
||||||
./tree.py 12 6 1 7 4 11 15 9 5 13 8 14 3 10 2 \| 6 2 12
|
./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
|
X.length $\gets$ 2 * n
|
||||||
\end{lstlisting}
|
\end{lstlisting}
|
||||||
%
|
%
|
||||||
The complexity of this algorithm is $O(n\log(n))$ since the sorting is in $\Theta(n\log(n))$ and the
|
The complexity of this algorithm is $O(n\log(n))$ since the sorting is in
|
||||||
union operation afterwards is $\Theta(n)$.
|
$\Theta(n\log(n))$ and the union operation afterwards is $\Theta(n)$.
|
||||||
|
|
||||||
\section{Bonus}
|
\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.
|
The number of possible trees with $n$ nodes can be defined recursively. The
|
||||||
Using math notation, the number $T_n$ of trees with $n$ nodes can be expressed as:
|
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 = 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}
|
\end{document}
|
Reference in a new issue