| @@ -0,0 +1,58 @@ | |||||
| \documentclass[uebung]{../../../lecture} | |||||
| \title{Übungsblatt Nr. 5} | |||||
| \author{Christian Merten, Samuel Weidemaier} | |||||
| \usepackage[]{enumerate} | |||||
| \usepackage{listings} | |||||
| \begin{document} | |||||
| \begin{aufgabe} Schleifeninvarianz | |||||
| \begin{enumerate}[(a)] | |||||
| \item $v = (a,b,i)$\\ | |||||
| $B(v)= i < n$ \\ | |||||
| $H(v)= (b, a+b, i+1)$ | |||||
| \item Hier $F$ Fibonacci Folge.\\ | |||||
| $INV(v^{j}) \equiv F(j) = a \land F(j+1) = b \land i - 1 < n$ | |||||
| Verifikation der Schleifeninvariante: | |||||
| \begin{enumerate}[1.] | |||||
| \item | |||||
| Für $v^{0} = (a^{0}, b^{0}, i^{0}) = (0, 1, 0)$ gilt: | |||||
| \[ | |||||
| INV(0,1,0) \equiv F(0) = 0 \land F(1) = 1 \land 0 - 1 < n | |||||
| .\] | |||||
| \item Es gelte nun $INV(v^{j}) \land B(v^{j})$. | |||||
| Wende $H$ auf $v^{j}$ an: | |||||
| \begin{itemize} | |||||
| \item | |||||
| $a_{j+1} = F(j+1) = b_j \land b_{j+1} = a_j + b_{j} = F(j) + F(j+1) = F(j+2)$ | |||||
| \item | |||||
| $i_{j+1} - 1 = i_{j} + 1 - 1 = i_j < n$ | |||||
| \end{itemize} | |||||
| \item | |||||
| Am Schleifenende gilt $\neg (i < n)$, also $i \ge n \land i - 1 < n \implies i = n$. | |||||
| \begin{align*} | |||||
| &INV(a, b, n-1) \land \neg B(v^{n-1}) \\ | |||||
| \iff & F(n-1) = a \land F(n) = b \land n - 1 < n \\ | |||||
| \iff &Q(v^{n}) | |||||
| .\end{align*} | |||||
| \end{enumerate} | |||||
| \end{enumerate} | |||||
| \end{aufgabe} | |||||
| \begin{aufgabe} | |||||
| siehe \textit{readSortedArray.ccp} | |||||
| \end{aufgabe} | |||||
| \begin{aufgabe} | |||||
| siehe \textit{perfectShuffle.cpp} | |||||
| \end{aufgabe} | |||||
| \end{document} | |||||