diff --git a/103_Elementare_Datenstrukturen.tex b/103_Elementare_Datenstrukturen.tex index ae13a5c11240cd7cb4f8a39c5e76cc82e7c15ca7..489f87ded8ac15382e1dcd33d85800374ad32cbd 100644 --- a/103_Elementare_Datenstrukturen.tex +++ b/103_Elementare_Datenstrukturen.tex @@ -145,11 +145,12 @@ $\mathcal{O}(1)$ Aufwand vonnöten ist. \\ \begin{algorithm}[H] \SetNlSty{texttt}{[}{]} \caption{\texttt{insert\textunderscore after}$((d,p), d')$} - \KwIn{A node $(d,p)$ to the list element after which to insert the new list element storing $d$} + \KwIn{A node $(d,p)$ to the list element after which to insert the new list element storing $d'$} \KwOut{Side effects in the memory $\mathcal{M}$} - new\_element = ($d$, \texttt{next}($\mathcal{M}$[p])) \; - \texttt{next}($\mathcal{M}[p]$) $\leftarrow$ \texttt{reference\_of}(new\_element)\; + new\_element $= (d', \texttt{pointer}(\texttt{next}((d,p))))$ \; + $\texttt{next}(\mathcal{M}[p]) \leftarrow \texttt{reference\_of}(new\_element)$\; \end{algorithm} +Hier gibt $\texttt{reference\_of}$ die Speicherposition des frisch erstellten Nodes zurück. \begin{figure}[!htb] \centering @@ -162,10 +163,10 @@ Auch für das Löschen ist nur das Umbiegen eines einzelnen Zeigers nötig, sieh \begin{algorithm}[H] \SetNlSty{texttt}{[}{]} - \caption{\texttt{delete\textunderscore after(p)}} - \KwIn{A pointer $p$ to the list element whose successor shall be removed from the list} - \KwOut{Side effects in the memory $\mathcal{M}$} - $\texttt{next}(\mathcal{M}[p]) \leftarrow \texttt{next}(\texttt{next}(\mathcal{M}[p]))$ \; + \caption{\texttt{delete\textunderscore after((d,p))}} + \KwIn{A node $(d,p)$ to the list element whose successor shall be removed from the list} + \KwOut{Side effects in the memory $\mathcal{M}$} + $((d,p)) \leftarrow (d, \texttt{pointer}(\texttt{next}((d,p))))$ \; \end{algorithm} \begin{figure}[!htb] @@ -204,7 +205,7 @@ Allerdings kann eine doppelt verkettete Liste als die natürlichste Datenstruktu werden. -\subsection{Stack} +\subsection{Stacks $\mathcal{S}$} Ein Stack $\mathcal{S}$ ist wie ein Stapel Teller: Hinzufügen oder Entnehmen von weiteren Tellern ist nur an der Spitze möglich. Viele Anwendungen brauchen genau das, aber auch nicht mehr. Beispielsweise das Umdrehen der Reihenfolge einer Sequenz, @@ -248,7 +249,7 @@ Auslesen, und dem Löschen: \\ Charmant für uns ist, dass alle Operationen auf Stacks jeweils $\mathcal{O}(1)$ Zeit brauchen, meist also vernachlässigbar sind. -\subsection{Queue} +\subsection{Queues $\mathcal{Q}$} Anders als der Stapel, der die LIFO-Strategie verfolgt, beschreibt die Queue eine (faire) Warteschlange: Wer als erstes da war, kommt als erstes dran. Man nennt es auch die FIFO-Strategie (first-in, first-out). Ansonsten hat auch sie zwei Funktion, $\texttt{put}$, das Hintanstellen, sowie $\texttt{get}$, das Drankommen.