Skip to content
Snippets Groups Projects
Commit fc89aa09 authored by Peter Gerwinski's avatar Peter Gerwinski
Browse files

Vortragsfolien 23.1.2017

parent 188e9970
No related branches found
No related tags found
No related merge requests found
File added
% hp-20170123.pdf - Lecture Slides on Low-Level Programming
% Copyright (C) 2012, 2013, 2015, 2016, 2017 Peter Gerwinski
%
% This document is free software: you can redistribute it and/or
% modify it either under the terms of the Creative Commons
% Attribution-ShareAlike 3.0 License, or under the terms of the
% GNU General Public License as published by the Free Software
% Foundation, either version 3 of the License, or (at your option)
% any later version.
%
% This document is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this document. If not, see <http://www.gnu.org/licenses/>.
%
% You should have received a copy of the Creative Commons
% Attribution-ShareAlike 3.0 Unported License along with this
% document. If not, see <http://creativecommons.org/licenses/>.
\documentclass[10pt,t]{beamer}
\usepackage{pgslides}
\usepackage{tikz}
\usepackage{rotating}
\title{Angewandte Informatik\\Hardwarenahe Programmierung}
\author{Prof.\ Dr.\ rer.\ nat.\ Peter Gerwinski}
\date{23.\ Januar 2017}
\begin{document}
\maketitleframe
\nosectionnonumber{\inserttitle}
\begin{frame}
\shownosectionnonumber
\begin{itemize}
\item[\textbf{1}] \textbf{Einführung}
\item[\textbf{2}] \textbf{Einführung in C}
\item[\textbf{3}] \textbf{Bibliotheken}
\item[\textbf{4}] \textbf{Algorithmen}
\item[\textbf{5}] \textbf{Hardwarenahe Programmierung}
\item[\textbf{6}] \textbf{Objektorientierte Programmierung}
\item[\textbf{7}] \textbf{Datenstrukturen}
\begin{itemize}
\color{medgreen}
\item[7.1] Stack und FIFO
\item[7.2] Verkettete Listen
\color{red}
\item[7.3] Bäume
\end{itemize}
\end{itemize}
\end{frame}
\newcommand{\half}{\protect\raisebox{0.5ex}{\small 1}\kern-0.1em/\kern-0.02em\protect\raisebox{-0.1ex}{\small 2}}
\setcounter{section}{6}
\section{Datenstrukturen}
\subsection{Stack und FIFO}
\begin{frame}[fragile]
\showsection
\showsubsection
\bigskip
\begin{minipage}[b]{6cm}
\begin{center}
"`First In -- First Out"'
\bigskip
\begin{picture}(6,4)
\thicklines
\color{structure}
\put(0.5,0){\line(1,0){5}}
\put(3.5,0){\only<1-5>{\line(0,1){1}}}
\put(4.5,0){\only<1-4>{\line(0,1){1}}}
\put(3.5,1){\only<1-4>{\line(1,0){1}}}
\put(4.0,0.5){\only<1-4>{\makebox(0,0){\lstinline{3}}}}
\put(3.0,1.5){\only<1>{\makebox(0,0)[tl]{\tikz{\draw[-latex, line width=1pt](0,0)--(0.45,-0.45);}}}}
\put(3.0,1.5){\only<1>{\makebox(0,0)[b]{\lstinline{push (3)}}}}
\put(2.5,0){\only<2-6>{\line(0,1){1}}}
\put(2.5,1){\only<2-5>{\line(1,0){1}}}
\put(3.0,0.5){\only<2-5>{\makebox(0,0){\lstinline{7}}}}
\put(2.0,1.5){\only<2>{\makebox(0,0)[tl]{\tikz{\draw[-latex, line width=1pt](0,0)--(0.45,-0.45);}}}}
\put(2.0,1.5){\only<2>{\makebox(0,0)[b]{\lstinline{push (7)}}}}
\put(1.5,0){\only<3-6>{\line(0,1){1}}}
\put(1.5,1){\only<3-6>{\line(1,0){1}}}
\put(2.0,0.5){\only<3-6>{\makebox(0,0){\lstinline{137}}}}
\put(1.0,1.5){\only<3>{\makebox(0,0)[tl]{\tikz{\draw[-latex, line width=1pt](0,0)--(0.45,-0.45);}}}}
\put(1.0,1.5){\only<3>{\makebox(0,0)[b]{\lstinline{push (137)}}}}
\put(4.55,1.05){\only<4>{\makebox(0,0)[bl]{\tikz{\draw[-latex, line width=1pt](0,0)--(0.45,0.45);}}}}
\put(5.00,1.60){\only<4>{\makebox(0,0)[b]{\lstinline{pop ()}: 3}}}
\put(3.55,1.05){\only<5>{\makebox(0,0)[bl]{\tikz{\draw[-latex, line width=1pt](0,0)--(0.45,0.45);}}}}
\put(4.00,1.60){\only<5>{\makebox(0,0)[b]{\lstinline{pop ()}: 7}}}
\put(2.55,1.05){\only<6>{\makebox(0,0)[bl]{\tikz{\draw[-latex, line width=1pt](0,0)--(0.45,0.45);}}}}
\put(3.00,1.60){\only<6>{\makebox(0,0)[b]{\lstinline{pop ()}: 137}}}
\end{picture}
\bigskip
FIFO = Queue = Reihe
\end{center}
\end{minipage}\hfill
\begin{minipage}[b]{6cm}
\begin{center}
"`Last In -- First Out"'
\bigskip
\begin{picture}(6,4)
\thicklines
\color{structure}
\put(1.5,0){\line(1,0){3}}
\put(2.5,0){\line(0,1){1}}
\put(3.5,0){\line(0,1){1}}
\put(2.5,1){\line(1,0){1}}
\put(3.0,0.5){\makebox(0,0){\lstinline{3}}}
\put(2.0,1.5){\only<1>{\makebox(0,0)[tl]{\tikz{\draw[-latex, line width=1pt](0,0)--(0.45,-0.45);}}}}
\put(2.0,1.5){\only<1>{\makebox(0,0)[b]{\lstinline{push (3)}}}}
\put(2.5,1){\only<2-5>{\line(0,1){1}}}
\put(3.5,1){\only<2-5>{\line(0,1){1}}}
\put(2.5,2){\only<2-5>{\line(1,0){1}}}
\put(3.0,1.5){\only<2-5>{\makebox(0,0){\lstinline{7}}}}
\put(2.0,2.5){\only<2>{\makebox(0,0)[tl]{\tikz{\draw[-latex, line width=1pt](0,0)--(0.45,-0.45);}}}}
\put(2.0,2.5){\only<2>{\makebox(0,0)[b]{\lstinline{push (7)}}}}
\put(2.5,2){\only<3-4>{\line(0,1){1}}}
\put(3.5,2){\only<3-4>{\line(0,1){1}}}
\put(2.5,3){\only<3-4>{\line(1,0){1}}}
\put(3.0,2.5){\only<3-4>{\makebox(0,0){\lstinline{137}}}}
\put(2.0,3.5){\only<3>{\makebox(0,0)[tl]{\tikz{\draw[-latex, line width=1pt](0,0)--(0.45,-0.45);}}}}
\put(2.0,3.5){\only<3>{\makebox(0,0)[b]{\lstinline{push (137)}}}}
\put(3.55,3.05){\only<4>{\makebox(0,0)[bl]{\tikz{\draw[-latex, line width=1pt](0,0)--(0.45,0.45);}}}}
\put(4.00,3.60){\only<4>{\makebox(0,0)[b]{\lstinline{pop ()}: 137}}}
\put(3.55,2.05){\only<5>{\makebox(0,0)[bl]{\tikz{\draw[-latex, line width=1pt](0,0)--(0.45,0.45);}}}}
\put(4.00,2.60){\only<5>{\makebox(0,0)[b]{\lstinline{pop ()}: 7}}}
\put(3.55,1.05){\only<6>{\makebox(0,0)[bl]{\tikz{\draw[-latex, line width=1pt](0,0)--(0.45,0.45);}}}}
\put(4.00,1.60){\only<6>{\makebox(0,0)[b]{\lstinline{pop ()}: 3}}}
\end{picture}
\bigskip
LIFO = Stack = Stapel
\end{center}
\end{minipage}
%
% \dots
\end{frame}
\begin{frame}[fragile]
\showsection
\showsubsection
\begin{minipage}{0.48\textwidth}
Im letzten Praktikumsversuch:
\begin{itemize}
\item
Array nur zum Teil benutzt
\item
Variable speichert genutzte Länge
\item
Elemente hinten anfügen\\
oder entfernen
\arrowitem
Stack
\end{itemize}
\bigskip
\begin{itemize}
\item
hinten anfügen/entfernen: $\mathcal{O}(1)$\hspace*{-1cm}
\item
vorne oder in der Mitte anfügen/entfernen: $\mathcal{O}(n)$
\end{itemize}
\end{minipage}\hfill
\begin{minipage}{0.51\textwidth}
Auch möglich:
\begin{itemize}
\item
Array nur zum Teil benutzt
\item
2 Variable speichern\\genutzte Länge (ringförmig)
\item
Elemente hinten anfügen\\
oder vorne entfernen
\arrowitem
FIFO
\end{itemize}
\bigskip
\begin{itemize}
\item
vorne oder hinten\\
anfügen oder entfernen: $\mathcal{O}(1)$
\item
in der Mitte anfügen/entfernen: $\mathcal{O}(n)$
\end{itemize}
\end{minipage}
\end{frame}
\begin{frame}
\showsection
\showsubsection
\bigskip
\begin{minipage}[t]{6cm}
Array (Stack, FIFO):\\
in der Mitte einfügen
\begin{center}
\begin{picture}(6,3.8)
\thicklines
\color{structure}
\put(1.5,0){\line(1,0){3}}
\put(2.5,0){\line(0,1){3}}
\put(3.5,0){\line(0,1){3}}
\put(2.5,1){\line(1,0){1}}
\put(3.0,0.5){\makebox(0,0){\lstinline{3}}}
\put(2.5,1){\line(1,0){1}}
\put(3.0,1.5){\makebox(0,0){\lstinline{7}}}
\put(2.5,2){\line(1,0){1}}
\put(3.0,2.5){\makebox(0,0){\lstinline{137}}}
\put(2.5,3){\line(1,0){1}}
\put(1.5,1.5){\makebox(0,0)[b]{\lstinline{push (5)}}}
\put(1.5,1.45){\makebox(0,0)[tl]{\tikz{\draw[-latex, line width=1pt](0,0)--(0.95,-0.45);}}}
\put(3.55,2.5){\makebox(0,0)[bl]{\tikz{\draw[-latex, line width=1pt](0,0)..controls(0.5,0.45)..(0,0.9);}}}
\put(3.55,1.5){\makebox(0,0)[bl]{\tikz{\draw[-latex, line width=1pt](0,0)..controls(0.5,0.45)..(0,0.9);}}}
\color{red}
\put(4.1,3.0){\makebox(0,0)[l]{\textbf{1.}}}
\put(4.1,2.0){\makebox(0,0)[l]{\textbf{2.}}}
\put(1.5,1.9){\makebox(0,0)[b]{\textbf{3.}}}
\put(6.0,1.5){\makebox(0,0)[tl]{$\mathcal{O}(n)$}}
\put(5.95,1.45){\makebox(0,0)[br]{\tikz{\draw[-latex](0,0)--(-1.3,0.4);}}}
\put(5.95,1.49){\makebox(0,0)[br]{\tikz{\draw[-latex](0,0)--(-1.3,1.1);}}}
\end{picture}
\end{center}
\end{minipage}\hfill
\begin{minipage}[t]{5cm}
In Array (Stack, FIFO) \dots
\begin{itemize}
\item
einfügen: $\mathcal{O}(n)$
\item
suchen: $\mathcal{O}(n)$
\item
geschickt suchen: $\mathcal{O}(\log n)$
\item
beim Einfügen sortieren:\\
$\mathcal{O}(n \log n)$ \hspace*{-1.8cm}\tikz{\draw[red](-1.8,0)--(0,0.2);\draw[red](-1.8,0.2)--(0,0);}
$\mathcal{O}(n^2)$
\end{itemize}
\end{minipage}
\end{frame}
\subsection{Verkettete Listen}
\begin{frame}
\showsection
\showsubsection
\begin{tikzpicture}
\color{structure}
\node(first) at (0,0.5) {first};
\node[shape=rectangle,draw,line width=1pt](3) at (1,2) {3};
\node[shape=rectangle,draw,line width=1pt](5) at (2,1) {5};
\node[shape=rectangle,draw,line width=1pt](7) at (3,2) {7};
\node[shape=rectangle,draw,line width=1pt](137) at (5,2) {137};
\node(NULL) at (7,2) {NULL};
\draw[-latex](first)--(3);
\only<1>{\draw[-latex](3)--(7);}
\only<2>{\draw[-latex](3) to[out=0] (5);}
\only<2>{\draw[-latex](5) to[in=180] (7);}
\draw[-latex](7)--(137);
\draw[-latex](137)--(NULL);
\end{tikzpicture}
\begin{itemize}
\item
Jeder Datensatz enthält einen Zeiger auf das nächste Element.
\item
Beim letzten Element zeigt der Zeiger auf \lstinline{NULL}.
\item
Eine Variable zeigt auf das erste Element.
\item
Wenn die Liste leer ist, zeigt die Variable auf \lstinline{NULL}.
\arrowitem
(einfach) \textbf{verkettete Liste}
\end{itemize}
\end{frame}
\begin{frame}
\showsection
\showsubsection
\begin{minipage}[t]{5cm}
In Array (Stack, FIFO) \dots
\begin{itemize}
\item
einfügen: $\mathcal{O}(n)$
\item
suchen: $\mathcal{O}(n)$
\item
geschickt suchen: $\mathcal{O}(\log n)$
\item
beim Einfügen sortieren:\\
$\mathcal{O}(n \log n)$ \hspace*{-1.8cm}\tikz{\draw[red](-1.8,0)--(0,0.2);\draw[red](-1.8,0.2)--(0,0);}
$\mathcal{O}(n^2)$
\end{itemize}
\end{minipage}\hfill
\begin{minipage}[t]{6cm}
In (einfach) verkettete/r Liste \dots
\begin{itemize}
\item
einfügen: $\mathcal{O}(1)$
\item
suchen: $\mathcal{O}(n)$
\item
geschickt \hspace*{-1.7cm}\tikz{\draw[red](-1.7,0)--(0,0.2);\draw[red](-1.7,0.2)--(0,0);}
suchen: {\color{red}$\mathcal{O}(n)$}
\item
beim Einfügen sortieren:
$\mathcal{O}(n \log n)$ \hspace*{-1.8cm}\tikz{\draw[red](-1.8,0)--(0,0.2);\draw[red](-1.8,0.2)--(0,0);}
$\mathcal{O}(n^2)$
\end{itemize}
\end{minipage}
\pause
\medskip
\begin{center}
\begin{minipage}[t]{6cm}
In (ausbalancierten) Bäumen \dots
\begin{itemize}
\item
einfügen: $\mathcal{O}(\log n)$
\item
suchen: $\mathcal{O}(\log n)$
\item
beim Einfügen sortieren:
$\mathcal{O}(n \log n)$
\end{itemize}
\end{minipage}
\end{center}
\end{frame}
\subsection{Bäume}
\begin{frame}[fragile]
\showsection
\showsubsection
\begin{minipage}[t]{5cm}
\vspace*{-6cm}
\begin{lstlisting}[gobble=6]
typedef struct node
{
int content;
struct node *left, *right;
} node;
\end{lstlisting}
\bigskip
\bigskip
\begin{onlyenv}<6->
\begin{itemize}
\item
Einfügen: rekursiv, $\mathcal{O}(\log n)$
\item
Suchen: rekursiv, $\mathcal{O}(\log n)$
\item
beim Einfügen sortieren:\\
rekursiv, $\mathcal{O}(n\log n)$
\begin{onlyenv}<7->
\smallskip
\item
{\color{red}
\emph{Worst Case\/}: $\mathcal{O}(n^2)$\\
vorher bereits sortiert}\\
\textarrow\ balancierte Bäume\\
\hspace*{2.15em}Anwendung: Datenbanken\hspace*{-2cm}
\end{onlyenv}
\end{itemize}
\vspace*{-1cm}
\end{onlyenv}
\end{minipage}\hfill
\begin{minipage}[t]{7cm}
\begin{center}
\begin{tikzpicture}
\color{structure}
\node(root) at (0,0) {\lstinline{node *root;}};
\begin{onlyenv}<2>
\node(3) at (-2,-3) {\lstinline{NULL}};
\node(137) at (2,-3) {\lstinline{NULL}};
\end{onlyenv}
\begin{onlyenv}<2->
\node[shape=rectangle,draw,line width=1pt](7) at (0,-1.5) {7};
\draw[-latex](root)--(7);
\draw[-latex](7)--(3);
\draw[-latex](7)--(137);
\end{onlyenv}
\begin{onlyenv}<3>
\node(3) at (-2,-3) {\lstinline{NULL}};
\end{onlyenv}
\begin{onlyenv}<3->
\node[shape=rectangle,draw,line width=1pt](137) at (2,-3) {137};
\node(137_left) at (1,-4.5) {\lstinline{NULL}};
\node(137_right) at (3,-4.5) {\lstinline{NULL}};
\draw[-latex](137)--(137_left);
\draw[-latex](137)--(137_right);
\end{onlyenv}
\begin{onlyenv}<4>
\node(5) at (-1,-4.5) {\lstinline{NULL}};
\end{onlyenv}
\begin{onlyenv}<4->
\node[shape=rectangle,draw,line width=1pt](3) at (-2,-3) {3};
\node(3_left) at (-3,-4.5) {\lstinline{NULL}};
\draw[-latex](3)--(3_left);
\draw[-latex](3)--(5);
\end{onlyenv}
\begin{onlyenv}<5->
\node[shape=rectangle,draw,line width=1pt](5) at (-1,-4.5) {5};
\node(5_left) at (-2,-6) {\lstinline{NULL}};
\node(5_right) at (0,-6) {\lstinline{NULL}};
\draw[-latex](5)--(5_left);
\draw[-latex](5)--(5_right);
\end{onlyenv}
\end{tikzpicture}
\end{center}
\end{minipage}
\end{frame}
\nosectionnonumber{\inserttitle}
\begin{frame}
\shownosectionnonumber
\begin{itemize}
\item[\textbf{1}] \textbf{Einführung}
\item[\textbf{2}] \textbf{Einführung in C}
\item[\textbf{3}] \textbf{Bibliotheken}
\item[\textbf{4}] \textbf{Algorithmen}
\item[\textbf{5}] \textbf{Hardwarenahe Programmierung}
\item[\textbf{6}] \textbf{Objektorientierte Programmierung}
\item[\textbf{7}] \textbf{Datenstrukturen}
\begin{itemize}
\item[7.1] Stack und FIFO
\item[7.2] Verkettete Listen
\color{medgreen}
\item[7.3] Bäume
\end{itemize}
\end{itemize}
\end{frame}
\begin{frame}
\shownosectionnonumber
\begin{itemize}
\item[\textbf{1}] \textbf{Einführung}
\item[\textbf{2}] \textbf{Einführung in C}
\item[\textbf{3}] \textbf{Bibliotheken}
\item[\textbf{4}] \textbf{Algorithmen}
\item[\textbf{5}] \textbf{Hardwarenahe Programmierung}
\item[\textbf{6}] \textbf{Objektorientierte Programmierung}
\item[\textbf{7}] \textbf{Datenstrukturen}
\begin{itemize}
\item[7.1] Stack und FIFO
\item[7.2] Verkettete Listen
\item[7.3] Bäume
\end{itemize}
\end{itemize}
\end{frame}
\end{document}
../common/logo-hochschule-bochum-cvh-text.pdf
\ No newline at end of file
../common/logo-hochschule-bochum.pdf
\ No newline at end of file
../common/pgscript.sty
\ No newline at end of file
../common/pgslides.sty
\ No newline at end of file
......@@ -31,6 +31,7 @@ Vortragsfolien:
* [02.01.2017: Special: Software und Urheberrecht, Exploits](https://gitlab.cvh-server.de/pgerwinski/hp/raw/master/20170102/hp-20170102.pdf)
* [09.01.2017: Objektorientierte Programmierung (virtuelle Methoden, C++), Datenstrukturen (Stack und FIFO)](https://gitlab.cvh-server.de/pgerwinski/hp/raw/master/20170109/hp-20170109.pdf)
* [16.01.2017: Datenstrukturen (Stack und FIFO, verkettete Listen)](https://gitlab.cvh-server.de/pgerwinski/hp/raw/master/20170116/hp-20170116.pdf)
* [23.01.2017: Datenstrukturen (verkettete Listen, Bäume)](https://gitlab.cvh-server.de/pgerwinski/hp/raw/master/20170116/hp-20170123.pdf)
* [alle in 1 Datei](https://gitlab.cvh-server.de/pgerwinski/hp/raw/master/hp-slides-2016ws.pdf)
Tafelbilder:
......
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment