diff options
author | Camil Staps | 2015-12-11 13:19:52 +0000 |
---|---|---|
committer | Camil Staps | 2015-12-11 13:19:52 +0000 |
commit | 52a67a6466a4bc10f809f1fb68e2db5830c05f64 (patch) | |
tree | 14557d69017ba5ef33ec724bc0859842d7da6fcc /Practical2/report/analysis.tex | |
parent | Practical 1; samples the program fails on (diff) |
Finish first version report practical 2
Some changes were made to the code and the Makefile to clean up, make it
more in line with the algorithm as described in the report, etc. No
significant changes.
Diffstat (limited to 'Practical2/report/analysis.tex')
-rw-r--r-- | Practical2/report/analysis.tex | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Practical2/report/analysis.tex b/Practical2/report/analysis.tex new file mode 100644 index 0000000..d989fe6 --- /dev/null +++ b/Practical2/report/analysis.tex @@ -0,0 +1,18 @@ +\section{Complexity analysis} +\label{sec:analysis} + +We iterate $p$ in $\pazocal O(|\bar a'|) = \pazocal O(|\bar a|)$. In every iteration we do two things: + +\begin{itemize} + \item We build $S$ in $\pazocal O(p)=\pazocal O(|\bar a|)$. + \item We iterate $d$ in $\pazocal O(k)$. Apart from the special cases that $p=0$ or $d=0$, we then have to iterate over $i$ in $\pazocal O(p)=\pazocal O(|\bar a|)$. + + The computations in this last loop take constant time: $\PR$ can be implemented in constant time as has been seen in \autoref{sec:implementation}, and computing the maximum can be done while iterating over $i$. +\end{itemize} + +This gives a total time complexity of $\pazocal O(k\cdot|\bar a|^2)$. + +\medskip + +The algorithm uses a two-dimensional array $G$ to store solutions to subproblems. This array uses $\pazocal O(k\cdot|\bar a|)$ space. The auxiliary array $S$ takes only linear space in $|\bar a|$ and can therefore be ignored in the overall space complexity. This gives the algorithm a space complexity of $\pazocal O(k\cdot|\bar a|)$. + |