59 lines
1.8 KiB
TeX
59 lines
1.8 KiB
TeX
\documentclass{../../../lecture}
|
|
|
|
\newcommand{\te}[1]{\underline{#1}}
|
|
|
|
\begin{document}
|
|
|
|
\begin{aufgabe}[Darstellung von binären Bäumen]
|
|
\end{aufgabe}
|
|
|
|
\textbf{a)}
|
|
|
|
\textit{Preorder}: +(*(:(8 3) 7) -(4 *(+(1 5) 2)))\\
|
|
\textit{Inorder}: (((8 : 3) * 7) + (4 - ((1 + 5) * 2)))\\
|
|
\textit{Postorder}: (((8 3): 7)* (4 ((1 5)+ 2)*)-)+
|
|
|
|
\textbf{b)}
|
|
|
|
Preorder und Postorder Darstellungen sind auch ohne Klammerung
|
|
oder Operator-Rangfolgen eindeutig, da
|
|
hier immer nur eine Möglichkeit existiert, den Operator anzuwenden,
|
|
nämlich auf die zwei Ausdrücke, die vor, bzw. hinter dem Operator stehen.
|
|
|
|
Bei Inorder Darstellung ist das nicht eindeutig.
|
|
|
|
\textbf{c)}
|
|
|
|
Die Reihenfolge \textit{Wurzel} - \textit{Rechts} - \textit{Links} ist
|
|
die Postorder Darstellung gespiegelt, da Postorder: \textit{Links}
|
|
\textit{Rechts} \textit{Wurzel}.
|
|
|
|
\begin{aufgabe}[Lineare Gleichungssysteme in EBNF]
|
|
\end{aufgabe}
|
|
|
|
\begin{tabular}{lcl}
|
|
<LGS> & ::= & <Gleichung> \{\te{\textbackslash n} <Gleichung>\}\\
|
|
<Gleichung> & ::= & \{<Summand>\}$^{+}$ \te{=} <Zahl> \\
|
|
<Summand> & ::= & $\left[+ \mid -\right]$ $[$<Zahl>$]$ \te{$x$} <Index>\\
|
|
<Zahl> & ::= & \{<Ziffer>\}$^{+}$ \\
|
|
<Index> & ::= & \{Indexziffer\}$^{+}$ \\
|
|
<Ziffer> & ::= & \te{0} | \te{1} | \te{2} | \te{3} | \te{4} | \te{5}
|
|
| \te{6} | \te{7} | \te{8} | \te{9} \\
|
|
<Indexziffer> & ::= & \te{$_{0}$} | \te{$_{1}$} | \te{$_{2}$} | \te{$_{3}$} | \te{$_{4}$} | \te{$_{5}$}
|
|
| \te{$_{6}$} | \te{$_{7}$} | \te{$_{8}$} | \te{$_{9}$} \\
|
|
\end{tabular}
|
|
|
|
Es ist nicht möglich, mir dieser EBNF-Grammatik sicherzustellen, dass die
|
|
Anzahl der Variablen und die Anzahl der Gleichungen gleich sind, da
|
|
keine gemeinsame Nummerierung verwendet wird.
|
|
|
|
\begin{aufgabe}[Schnelle Potenzberechnung]
|
|
\end{aufgabe}
|
|
siehe \textit{uebung2.cpp}
|
|
|
|
\begin{aufgabe}[Vollkommene Zahlen]
|
|
\end{aufgabe}
|
|
siehe \textit{uebung2.cpp}
|
|
|
|
\end{document}
|