diff --git a/20230316/Zeichen_123.pdf b/20240404/Zeichen_123.pdf similarity index 100% rename from 20230316/Zeichen_123.pdf rename to 20240404/Zeichen_123.pdf diff --git a/20230316/ad-20240404.pdf b/20240404/ad-20240404.pdf similarity index 100% rename from 20230316/ad-20240404.pdf rename to 20240404/ad-20240404.pdf diff --git a/20230316/ad-20240404.tex b/20240404/ad-20240404.tex similarity index 100% rename from 20230316/ad-20240404.tex rename to 20240404/ad-20240404.tex diff --git a/20230316/ad-20240404.txt b/20240404/ad-20240404.txt similarity index 100% rename from 20230316/ad-20240404.txt rename to 20240404/ad-20240404.txt diff --git a/20230316/add-01-O0.s b/20240404/add-01-O0.s similarity index 100% rename from 20230316/add-01-O0.s rename to 20240404/add-01-O0.s diff --git a/20230316/add-01-O1.s b/20240404/add-01-O1.s similarity index 100% rename from 20230316/add-01-O1.s rename to 20240404/add-01-O1.s diff --git a/20230316/add-01-m32-O0.s b/20240404/add-01-m32-O0.s similarity index 100% rename from 20230316/add-01-m32-O0.s rename to 20240404/add-01-m32-O0.s diff --git a/20230316/add-01-m32-O1.s b/20240404/add-01-m32-O1.s similarity index 100% rename from 20230316/add-01-m32-O1.s rename to 20240404/add-01-m32-O1.s diff --git a/20230316/add-01.c b/20240404/add-01.c similarity index 100% rename from 20230316/add-01.c rename to 20240404/add-01.c diff --git a/20230316/add-02.c b/20240404/add-02.c similarity index 100% rename from 20230316/add-02.c rename to 20240404/add-02.c diff --git a/20230316/arrays-and-pointers-01.c b/20240404/arrays-and-pointers-01.c similarity index 100% rename from 20230316/arrays-and-pointers-01.c rename to 20240404/arrays-and-pointers-01.c diff --git a/20230316/arrays-and-pointers-02.c b/20240404/arrays-and-pointers-02.c similarity index 100% rename from 20230316/arrays-and-pointers-02.c rename to 20240404/arrays-and-pointers-02.c diff --git a/20230316/arrays-and-pointers-03.c b/20240404/arrays-and-pointers-03.c similarity index 100% rename from 20230316/arrays-and-pointers-03.c rename to 20240404/arrays-and-pointers-03.c diff --git a/20230316/arrays-and-pointers-04.c b/20240404/arrays-and-pointers-04.c similarity index 100% rename from 20230316/arrays-and-pointers-04.c rename to 20240404/arrays-and-pointers-04.c diff --git a/20230316/arrays-and-pointers-05.c b/20240404/arrays-and-pointers-05.c similarity index 100% rename from 20230316/arrays-and-pointers-05.c rename to 20240404/arrays-and-pointers-05.c diff --git a/20230316/arrays-and-pointers-06.c b/20240404/arrays-and-pointers-06.c similarity index 100% rename from 20230316/arrays-and-pointers-06.c rename to 20240404/arrays-and-pointers-06.c diff --git a/20230316/arrays-and-pointers-07.c b/20240404/arrays-and-pointers-07.c similarity index 100% rename from 20230316/arrays-and-pointers-07.c rename to 20240404/arrays-and-pointers-07.c diff --git a/20230316/arrays-and-pointers-08.c b/20240404/arrays-and-pointers-08.c similarity index 100% rename from 20230316/arrays-and-pointers-08.c rename to 20240404/arrays-and-pointers-08.c diff --git a/20230316/arrays-and-pointers-09.c b/20240404/arrays-and-pointers-09.c similarity index 100% rename from 20230316/arrays-and-pointers-09.c rename to 20240404/arrays-and-pointers-09.c diff --git a/20230316/arrays-and-pointers-10.c b/20240404/arrays-and-pointers-10.c similarity index 100% rename from 20230316/arrays-and-pointers-10.c rename to 20240404/arrays-and-pointers-10.c diff --git a/20230316/arrays-and-pointers-11.c b/20240404/arrays-and-pointers-11.c similarity index 100% rename from 20230316/arrays-and-pointers-11.c rename to 20240404/arrays-and-pointers-11.c diff --git a/20230316/arrays-and-pointers-12.c b/20240404/arrays-and-pointers-12.c similarity index 100% rename from 20230316/arrays-and-pointers-12.c rename to 20240404/arrays-and-pointers-12.c diff --git a/20230316/arrays-and-pointers-13.c b/20240404/arrays-and-pointers-13.c similarity index 100% rename from 20230316/arrays-and-pointers-13.c rename to 20240404/arrays-and-pointers-13.c diff --git a/20230316/arrays-and-pointers-14.c b/20240404/arrays-and-pointers-14.c similarity index 100% rename from 20230316/arrays-and-pointers-14.c rename to 20240404/arrays-and-pointers-14.c diff --git a/20230316/arrays-and-pointers-15.c b/20240404/arrays-and-pointers-15.c similarity index 100% rename from 20230316/arrays-and-pointers-15.c rename to 20240404/arrays-and-pointers-15.c diff --git a/20230316/arrays-and-pointers-16.c b/20240404/arrays-and-pointers-16.c similarity index 100% rename from 20230316/arrays-and-pointers-16.c rename to 20240404/arrays-and-pointers-16.c diff --git a/20230316/arrays-and-pointers-17.c b/20240404/arrays-and-pointers-17.c similarity index 100% rename from 20230316/arrays-and-pointers-17.c rename to 20240404/arrays-and-pointers-17.c diff --git a/20230316/arrays-and-pointers-18.c b/20240404/arrays-and-pointers-18.c similarity index 100% rename from 20230316/arrays-and-pointers-18.c rename to 20240404/arrays-and-pointers-18.c diff --git a/20230316/arrays-and-pointers-19.c b/20240404/arrays-and-pointers-19.c similarity index 100% rename from 20230316/arrays-and-pointers-19.c rename to 20240404/arrays-and-pointers-19.c diff --git a/20230316/arrays-and-pointers-20.c b/20240404/arrays-and-pointers-20.c similarity index 100% rename from 20230316/arrays-and-pointers-20.c rename to 20240404/arrays-and-pointers-20.c diff --git a/20230316/arrays-and-pointers-21.c b/20240404/arrays-and-pointers-21.c similarity index 100% rename from 20230316/arrays-and-pointers-21.c rename to 20240404/arrays-and-pointers-21.c diff --git a/20230316/arrays-and-pointers-21.s b/20240404/arrays-and-pointers-21.s similarity index 100% rename from 20230316/arrays-and-pointers-21.s rename to 20240404/arrays-and-pointers-21.s diff --git a/20230316/arrays-and-pointers-22.s b/20240404/arrays-and-pointers-22.s similarity index 100% rename from 20230316/arrays-and-pointers-22.s rename to 20240404/arrays-and-pointers-22.s diff --git a/20230316/landau-symbols-2.pdf b/20240404/landau-symbols-2.pdf similarity index 100% rename from 20230316/landau-symbols-2.pdf rename to 20240404/landau-symbols-2.pdf diff --git a/20230316/landau-symbols-3.pdf b/20240404/landau-symbols-3.pdf similarity index 100% rename from 20230316/landau-symbols-3.pdf rename to 20240404/landau-symbols-3.pdf diff --git a/20230316/landau-symbols.pdf b/20240404/landau-symbols.pdf similarity index 100% rename from 20230316/landau-symbols.pdf rename to 20240404/landau-symbols.pdf diff --git a/20230316/logo-hochschule-bochum-cvh-text.pdf b/20240404/logo-hochschule-bochum-cvh-text.pdf similarity index 100% rename from 20230316/logo-hochschule-bochum-cvh-text.pdf rename to 20240404/logo-hochschule-bochum-cvh-text.pdf diff --git a/20230316/logo-hochschule-bochum.pdf b/20240404/logo-hochschule-bochum.pdf similarity index 100% rename from 20230316/logo-hochschule-bochum.pdf rename to 20240404/logo-hochschule-bochum.pdf diff --git a/20230316/pgslides.sty b/20240404/pgslides.sty similarity index 100% rename from 20230316/pgslides.sty rename to 20240404/pgslides.sty diff --git a/20240411/Zeichen_123.pdf b/20240411/Zeichen_123.pdf new file mode 120000 index 0000000000000000000000000000000000000000..fdbc897227df059cfda790a16555e6e417682116 --- /dev/null +++ b/20240411/Zeichen_123.pdf @@ -0,0 +1 @@ +../common/Zeichen_123.pdf \ No newline at end of file diff --git a/20240411/ad-20240411.pdf b/20240411/ad-20240411.pdf new file mode 100644 index 0000000000000000000000000000000000000000..fb1b16f87d9576c17e1b275df82efeee884e885e Binary files /dev/null and b/20240411/ad-20240411.pdf differ diff --git a/20240411/ad-20240411.tex b/20240411/ad-20240411.tex new file mode 100644 index 0000000000000000000000000000000000000000..45d595c079d8c6aacabe5a1360487bd33ed32717 --- /dev/null +++ b/20240411/ad-20240411.tex @@ -0,0 +1,920 @@ +% ad-20240411.pdf - Lecture Slides on Algorithms and Data Structures in C/C++ +% Copyright (C) 2018, 2019, 2020, 2021, 2022, 2023, 2024 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/>. + +% README: Mathematische Grundlagen der Kryptographie + +\documentclass[10pt,t]{beamer} + +\usepackage{pgslides} +\usepackage{tikz} +%\usepackage{rotating} + +\newcommand{\underconstruction}{% + \begin{picture}(0,0) + \color{black} + \put(6,-2.2){\makebox(0,0)[b]{\includegraphics[width=1.5cm]{Zeichen_123.pdf}}} + \put(6,-2.5){\makebox(0,0)[t]{\shortstack{Änderungen\\vorbehalten}}} + \end{picture}} + +\title{Algorithmen und Datenstrukturen in C/C++} +\author{Prof.\ Dr.\ rer.\ nat.\ Peter Gerwinski} +\date{11.\ April 2024} + +\begin{document} + +\maketitleframe + +% \sectionnonumber{Vorab: Online-Werkzeuge} +% +% \begin{frame} +% +% \showsectionnonumber +% \begin{itemize} +% \item +% \textbf{Mumble}: Seminarraum 2\\ +% Fragen: Mikrophon einschalten oder über den Chat\\ +% Umfragen: über den Chat +% \smallskip +% \item +% \textbf{VNC}: Kanal 6, Passwort: \lstinline[style=cmd]{testcvh}\\ +% Eigenen Bildschirm freigeben: per VNC-Server oder Web-Interface\\ +% Kamerabild übertragen: Link zu Web-Interface auf Anfrage +% \smallskip +% \item +% Allgemeine Informationen: +% \url{https://www.cvh-server.de/online-werkzeuge/} +% \smallskip +% \item +% Notfall-Schnellzugang: \url{https://www.cvh-server.de/virtuelle-raeume/}\\ +% Seminarraum 2, VNC-Passwort: \lstinline[style=cmd]{testcvh} +% \smallskip +% \item +% Bei Problemen: bitte notieren:\\ +% Art des Problems, genaue Uhrzeit, JavaScript-Fehlermeldungen (F12) +% \bigskip +% \item +% GitLab: \url{https://gitlab.cvh-server.de/pgerwinski/ad}\\ +% Links auf die Datei klicken, nicht mittig auf den Kommentar. +% \end{itemize} +% +% \end{frame} + +\nosectionnonumber{Hardwarenahe Programmierung} + +\iffalse + +\begin{frame} + + \shownosectionnonumber + + \begin{itemize} + \item[\textbf{1}] \textbf{Einführung} + \hfill\makebox(0,0)[br]{\raisebox{2.25ex}{\url{https://gitlab.cvh-server.de/pgerwinski/hp}}} + \item[\textbf{2}] \textbf{Einführung in C} + \item[\textbf{3}] \textbf{Bibliotheken} + \item[\textbf{4}] \textbf{Hardwarenahe Programmierung} + \item[\textbf{5}] \textbf{\color{black}Algorithmen} + \begin{itemize} + \color{medgreen} + \item[5.1] Differentialgleichungen + \item[5.2] Rekursion + \item[5.3] Aufwandsabschätzungen + \end{itemize} + \item[\textbf{6}] \textbf{Objektorientierte Programmierung} + \item[\textbf{7}] \textbf{\color{black}Datenstrukturen} + \begin{itemize} + \color{medgreen} + \item[7.1] Stack und FIFO + \item[7.2] Verkettete Listen + \item[7.3] Bäume + \end{itemize} + \end{itemize} + \vspace*{-1cm} + +\end{frame} + +\fi + +\begin{frame} + + \shownosectionnonumber + + \begin{itemize} + \color{gray} + \item[\textbf{1}] \textbf{Einführung} + \hfill\makebox(0,0)[br]{\raisebox{2.25ex}{\url{https://gitlab.cvh-server.de/pgerwinski/hp}}} + \item[\textbf{2}] \textbf{Einführung in C} + \item[\textbf{3}] \textbf{Bibliotheken} + \item[\textbf{4}] \textbf{Hardwarenahe Programmierung} + \item[\textbf{5}] \textbf{\color{black}Algorithmen} + \begin{itemize} + \color{medgreen} + \item[5.1] Differentialgleichungen + \item[5.2] Rekursion + \item[5.3] Aufwandsabschätzungen + \end{itemize} + \item[\textbf{6}] \textbf{Objektorientierte Programmierung} + \item[\textbf{7}] \textbf{\color{black}Datenstrukturen} + \begin{itemize} + \color{medgreen} + \item[7.1] Stack und FIFO + \item[7.2] Verkettete Listen + \item[7.3] Bäume + \end{itemize} + \end{itemize} + \vspace*{-1cm} + +\end{frame} + +\nosectionnonumber{Algorithmen} + +\begin{frame} + + \shownosectionnonumber + + {\color{medgreen}\textbf{Differentialgleichungen}} + \begin{itemize} + \item Pendel + \item Planetenbahnen + \end{itemize} + + {\color{medgreen}\textbf{Rekursion}} + \begin{itemize} + \item Türme von Hanoi + \end{itemize} + + \smallskip + + \textarrow\ \emph{Wie rechnet man das überhaupt aus?} + + \bigskip + + {\color{medgreen}\textbf{Aufwandsabschätzungen}} + \begin{itemize} + \item Selectionsort + \item Bubblesort + \item Quicksort + \end{itemize} + + \smallskip + + \textarrow\ \emph{Wie rechnet man das möglichst effizient aus?} + \begin{itemize} + \item[\textbf{?}] möglichst schnell + \item[\textbf{?}] mit möglichst wenig Speicherplatzverbrauch + \item[\textbf{?}] unter Berücksichtigung gegebener Randbedingungen + \end{itemize} + +\end{frame} + +\nosectionnonumber{Datenstrukturen} + +\begin{frame} + + \shownosectionnonumber + + \addvspace{-3pt} + + \begin{visibleenv}<1-> + \textbf{Structs und Objekte} + \begin{itemize} + \item zusammengehörige Daten gemeinsam speichern + \end{itemize} + \end{visibleenv} + + {\color{medgreen}\textbf{Stack und FIFO}}\only<1->{\textbf{ -- Arrays}} + \begin{itemize} + \item effizientes Anfügen und Entfernen vorne und hinten + \item effizienter direkter Zugriff auf Elemente in der Mitte + \item ineffizientes Einfügen und Entfernen in der Mitte + \end{itemize} + + {\color{medgreen}\textbf{Verkettete Listen}}\only<1->{\textbf{ -- Structs mit Pointern}} + \begin{itemize} + \item effizientes Einfügen und Entfernen in der Mitte + \item ineffizienter direkter Zugriff auf Elemente in der Mitte + \end{itemize} + + {\color{medgreen}\textbf{Bäume}}\only<1->{\textbf{ -- Structs mit Pointern}} + \begin{itemize} + \item Kompromiß + \end{itemize} + + \smallskip + + \textarrow\ \emph{Wie speichert man das möglichst effizient?} + \begin{itemize} + \item[\textbf{?}] möglichst schnell + \item[\textbf{?}] mit möglichst wenig Speicherplatzverbrauch + \item[\textbf{?}] unter Berücksichtigung gegebener Randbedingungen + \end{itemize} + +\end{frame} + +\nosectionnonumber{Aufwandsabschätzungen \protect\color{gray}-- Komplexitätsanalyse} + +\begin{frame}[fragile] + +% \newcommand{\w}{\hspace*{0.75pt}} + + \shownosectionnonumber + + \begin{picture}(0,0) + \put(7.6,-0.5){% + \begin{minipage}[t]{5.3cm} +% \vspace*{-1.0cm}\includegraphics{landau-symbols.pdf} + \alt<3->{\vspace*{-0.93cm}\includegraphics{landau-symbols-3.pdf}}% + {\vspace*{-1.00cm}\includegraphics{landau-symbols.pdf}} + \small%\vspace*{-1.0cm} + \begin{description}\itemsep0pt\leftskip-0.5cm + \item[$n$:] Eingabedaten + \item[$g(n)$:] Rechenzeit + \end{description} + \end{minipage}} + \end{picture} + + \vspace*{-\bigskipamount} + + Wann ist ein Programm "`schnell"'? + + \medskip + + \begin{onlyenv}<1> + Türme von Hanoi: $\mathcal{O}(2^n)$ + \par\medskip + Für jede zusätzliche Scheibe\\verdoppelt sich die Rechenzeit! + \begin{itemize} + \arrowitem + $\frac{30,672\,\text{s}\,\cdot\,2^{32}}{3600\,\cdot\,24\,\cdot\,365,25} \approx 4174$ + Jahre\\[\smallskipamount] + für 64 Scheiben + \end{itemize} + + \bigskip + \end{onlyenv} + + \begin{onlyenv}<1-> + Faustregel:\\Schachtelung der Schleifen zählen\\ + $k$ Schleifen ineinander \textarrow\ $\mathcal{O}(n^k)$ + + \bigskip + \end{onlyenv} + + \begin{onlyenv}<2> + \textbf{Beispiel: Sortieralgorithmen} + + \smallskip + + Anzahl der Vergleiche bei $n$ Strings + \begin{itemize} + \item + Maximum suchen mit Schummeln: $\mathcal{O}(1)$ +% \pause + \item + Maximum suchen: $\mathcal{O}(n)$ +% \pause + \item + Selection-Sort: $\mathcal{O}(n^2)$ +% \pause + \item + Bubble-Sort: $\mathcal{O}(n)$ bis $\mathcal{O}(n^2)$ +% \pause + \item + Quicksort: $\mathcal{O}(n\log n)$ bis $\mathcal{O}(n^2)$ + \end{itemize} + + \end{onlyenv} + +% \begin{onlyenv}<3> +% \textbf{Wie schnell ist RSA-Verschlüsselung?} +% +% \smallskip +% +% \begin{math} +% c = m^e\,\%\,N +% \end{math} +% \quad +% ("`$\%$"' = "`modulo"') +% +% \medskip +% +% \begin{lstlisting}[gobble=6,xleftmargin=2em] +% int c = 1; +% for (int i = 0; i < e; i++) +% c = (c * m) % N; +% \end{lstlisting} +% +% \smallskip +% +% \begin{itemize} +% \item +% $\mathcal{O}(e)$ Iterationen +% % \item +% % wenn $n$ die Anzahl der Binärziffern (Bits) von $e$ ist: +% % $\mathcal{O}(2^n)$ Iterationen +% \item +% mit Trick: +% $\mathcal{O}(\log e)$ Iterationen ($\log e$ = Anzahl der Ziffern von $e$) +% \end{itemize} +% +% \smallskip +% +% Jede Iteration enthält eine Multiplikation und eine Division.\\ +% Aufwand dafür: $\mathcal{O}(\log e)$\\ +% \textarrow\ Gesamtaufwand: $\mathcal{O}\bigl((\log e)^2\bigr)$ +% +% \end{onlyenv} + + \begin{onlyenv}<3-> + + \textbf{Wie schnell ist RSA?}\\ + + \smallskip + + ($n$ = typische beteiligte Zahl, z.\,B. $e,p,q$) + + \begin{itemize} + \item + Ver- und Entschlüsselung (Exponentiation):\\ + \strut\hbox to 3.5cm{\color{red}$\mathcal{O}\!\left((\log n)^2\right)$\hss} + \only<3->{{\color{magenta}$\mathcal{O}(n^2)$}} + \item + Schlüsselerzeugung (Berechnung von $d$):\\ + \strut\hbox to 3.5cm{\color{red}$\mathcal{O}\!\left((\log n)^2\right)$\hss} + \only<3->{{\color{magenta}$\mathcal{O}(n^2)$}} + \item + Verschlüsselung brechen (Primfaktorzerlegung):\\ + \strut\hbox to 3.5cm{\color{red}$\mathcal{O}\bigl(2^{\sqrt{\log n\,\cdot\,\log\log n}}\bigr)$\hss} + \only<3->{{\color{magenta}$\mathcal{O}\bigl(2^{\sqrt{n\log n}}\bigr)$}} + \end{itemize} + + \smallskip +% \vspace{0cm plus 1filll} + + \textbf{Die Sicherheit von RSA beruht darauf, + daß das Brechen der Verschlüsselung aufwendiger ist als + \boldmath$\mathcal{O}\bigl((\log n)^k\bigr)$ (für beliebiges $k$).} + +% \vspace*{0.65cm} + + \pause[4] + \smallskip + \hspace*{2.29cm}\textcolor{red}{\textbf{Mit Quantencomputer: \boldmath$\mathcal{O}\bigl((\log n)^3\bigr)$}} + + \end{onlyenv} + +\end{frame} + +\nosectionnonumber{\inserttitle} + +\iffalse + +\begin{frame} + + \shownosectionnonumber + + \begin{itemize} + \item[\textbf{1}] \textbf{Einführung} + \hfill\makebox(0,0)[br]{\raisebox{2.25ex}{\url{https://gitlab.cvh-server.de/pgerwinski/ad}}} + \item[\textbf{2}] \textbf{\dots} + \end{itemize} + + \begin{picture}(0,0)(-2,-0.5) + \put(0.5,-1.0){\mbox{\Large$\mathcal{O}(n\log n)$}} + \put(0.6,-2.7){\mbox{\large\bf B-Baum}} + \put(-1.3,-3.4){\mbox{\small\it verkettete Liste}} + \put(1.5,-4.0){\mbox{\large Datenbanken}} + \put(-1.0,-1.9){\mbox{\large\tt struct}} + \put(3.0,-2.0){\mbox{\large Wegfindung}} + \put(4.0,-3.0){\mbox{Verschlüsseln}} + \put(5.7,-4.2){\mbox{\it Datenkompression}} + \put(6.0,-1.5){\mbox{CORDIC}} + \put(8.5,-2.0){\mbox{\small\bf FFT}} + \put(7.5,-2.9){\mbox{\small\tt pointer}} + \put(3.5,-0.5){\mbox{\it Rasterung}} + \put(7.7,-0.7){\mbox{\tt array}} + \put(-0.5,-5.0){\mbox{digitale Signatur}} + \put(3.5,-5.2){\mbox{\large Hash-Tabelle}} + \put(0.0,-6.3){\mbox{\small\bf kryptographische Hash-Funktion}} + \put(6.5,-6.0){\mbox{\it Prüfsumme}} +% \pause +% \put(4.0,-2.7){\begin{rotate}{18} +% \makebox(0,0){\LARGE\color{red}\shortstack{% +% Online-Werkzeuge für Home Office, Lehre\\ +% und Kommunikation mit Unterdrückten}} +% \end{rotate}} + \end{picture} + +\end{frame} + +\fi + +\begin{frame} + + \shownosectionnonumber + + \begin{itemize} + \item[\textbf{1}] \textbf{Einführung} + \underconstruction + \hfill\makebox(0,0)[br]{\raisebox{2.25ex}{\url{https://gitlab.cvh-server.de/pgerwinski/ad}}} +% \item[\textbf{\color{red}i}] {\color{red}Online-Werkzeuge für Home Office, Lehre\\ +% und Kommunikation mit Unterdrückten} + \item[\textbf{2}] \textbf{Arrays und Zeiger für Fortgeschrittene} + \item[\textbf{3}] \textbf{Langzahl-Arithmetik} + \item[\textbf{4}] \textbf{Kryptographie} + \item[\textbf{5}] \textbf{C++} + \item[\textbf{6}] \textbf{Datenorganisation} + \vspace{-\smallskipamount} + \item[\textbf{\dots}] + \end{itemize} + +\end{frame} + +\setcounter{section}{1} +\section{Arrays und Zeiger für Fortgeschrittene} + +\begin{frame}[fragile] + \showsection + + \begin{minipage}[t]{6cm} + Array: + \smallskip + \begin{lstlisting}[gobble=6] + char a[] = "Test"; + \end{lstlisting} + \end{minipage}\hfill + \begin{minipage}[t]{6cm} + Zeiger: + \smallskip + \begin{lstlisting}[gobble=6] + char *p = "Test"; + \end{lstlisting} + \end{minipage} + + \bigskip + + \begin{itemize} + \item + In beiden Fällen wird ein Array von ganzen Zahlen\\ + (5 \lstinline{char}-Variable mit den Werten 84, 101, 115, 116 und 0)\\ + im Speicher angelegt. + \medskip + \item + Links heißt das Array \lstinline{a}; + rechts ist es "`anonym"'. + \item + Rechts wird zusätzlich ein Zeiger \lstinline{p} im Speicher angelegt,\\ + der auf das (anonyme) Array zeigt. + \medskip + \item + \lstinline{&a} ist dasselbe wie \lstinline{a}, + nämlich die Adresse des Arrays. + \item + \lstinline{&p} ist die Adresse des Zeigers. + \item + \lstinline{p} ist der Wert des Zeigers,\\ + momentan also die Adresse des (anonymen) Arrays. + \end{itemize} + +\end{frame} + +\begin{frame}[fragile] + \showsection + + \begin{minipage}[t]{6cm} + Array: + \smallskip + \begin{lstlisting}[gobble=6] + char a[] = "Test"; + \end{lstlisting} + \end{minipage}\hfill + \begin{minipage}[t]{6cm} + Zeiger: + \smallskip + \begin{lstlisting}[gobble=6] + char *p = "Test"; + \end{lstlisting} + \end{minipage} + + \bigskip + + \begin{itemize} + \item + In beiden Fällen wird ein Array von ganzen Zahlen\\ + (5 \lstinline{char}-Variable mit den Werten 84, 101, 115, 116 und 0)\\ + im Speicher angelegt. + \medskip + \item + Links heißt das Array \lstinline{a}; + rechts ist es "`anonym"'. + \item + Rechts wird zusätzlich ein Zeiger \lstinline{p} im Speicher angelegt,\\ + der auf das (anonyme) Array zeigt. + \medskip + \item + \lstinline{&a} ist {\color{red}fast} dasselbe wie \lstinline{a},\\ + nämlich die Adresse des Arrays {\color{red}bzw.\ das Array selbst,\\ + das zuweisungskompatibel zu einem Zeiger auf Elemente des Arrays ist.\\ + \lstinline{&} bewirkt hier eine (nicht explizite!) Typumwandlung.} + \item + \lstinline{&p} ist die Adresse des Zeigers. + \item + \lstinline{p} ist der Wert des Zeigers,\\ + momentan also die Adresse des (anonymen) Arrays. + \end{itemize} + + \vspace*{-1cm} + +\end{frame} + +\begin{frame}[fragile] + \showsection + + \begin{minipage}[t]{7cm} + Array: + \smallskip + \begin{lstlisting}[gobble=6] + char *a[] = { "Dies", "ist", "ein", "Test" }; + \end{lstlisting} + \end{minipage}\hfill + \begin{minipage}[t]{5cm} + Zeiger: + \smallskip + \begin{lstlisting}[gobble=6] + char **p = a; + \end{lstlisting} + \end{minipage} + + \bigskip + + \begin{itemize} + \item + Array von Zeigern auf \lstinline{char}-Variable + \item + Zeiger auf das Array = Zeiger auf Zeiger auf \lstinline{char}-Variable + \item + Schleife durch äußeres Array mit \lstinline{p++} möglich + \end{itemize} + +\end{frame} + +\begin{frame}[fragile] + \showsection + + \begin{minipage}[t]{7cm} + Array: + \smallskip + \begin{lstlisting}[gobble=6] + char a[][5] = { "Dies", "ist", "ein", "Test" }; + \end{lstlisting} + \end{minipage}\hfill + \begin{minipage}[t]{5cm} + Zeiger: + \smallskip + \begin{lstlisting}[gobble=6] + char *p = a[0]; + \end{lstlisting} + \end{minipage} + + \bigskip + + \begin{itemize} + \item + zweidimensionales Array von \lstinline{char}-Variablen + \item + Zeiger auf Array-Komponente\\ + = Zeiger auf eindimensionales Array\\ + = Zeiger auf \lstinline{char}-Variable + \item + Schleife durch äußeres Array mit Zeiger-Arithmetik nicht möglich + \end{itemize} + + \begin{picture}(0,0) + \color{red} + \thicklines + \put(8.6,0.63){\line(1,0){0.85}} + \put(9.05,0.4){\makebox(0,0)[t]{$\overbrace{\mbox{nur mit Trick: + \lstinline{p += 5}}}$}} + \end{picture} + +\end{frame} + +\begin{frame}[fragile] + \showsection + + \begin{lstlisting} + typedef char string5[5]; + string5 a[] = { "Dies", "ist", "ein", "Test" }; + string5 *p = a; + \end{lstlisting} + + \bigskip + + \begin{itemize} + \item + Array von Array von \lstinline{char}-Variablen\\ + = zweidimensionales Array von \lstinline{char}-Variablen + \item + Zeiger auf zweidimensionales Array + \item + Schleife durch äußeres Array mit \lstinline{p++} möglich + \bigskip + \arrowitem + Fazit:\\ + Ein Hoch auf \lstinline{typedef}! + \arrowitem + Trotzdem: {\color{red}Vorsicht!}\\ + Ein \lstinline{p++} auf einen Zeiger vom Typ \lstinline{string5 *p}\\ + ergibt anscheinend undefiniertes Verhalten! + \end{itemize} + +\end{frame} + +\begin{frame}[fragile] + \showsection + + \begin{lstlisting} + typedef char string5[5]; + string5 *p = { "Dies", "ist", "ein", "Test" }; + \end{lstlisting} + + \bigskip + + \begin{itemize} + \item + anonymes Array von Array von \lstinline{char}-Variablen\\ + = anonymes zweidimensionales Array von \lstinline{char}-Variablen + \item + Zeiger auf zweidimensionales Array + \item + Schleife durch äußeres Array mit \lstinline{p++} möglich + \end{itemize} + +% \pause + + \begin{picture}(0,0)(-2,-0.4) + \color{red} + \thicklines + \put(0,0){\line(2,1){4}} + \put(0,2){\line(2,-1){4}} + \end{picture} + + Das Konstrukt \lstinline|{ "Dies", "ist", "ein", "Test" }|\\ + steht für ein Array von 4 Zeigern auf \lstinline{char}-Variable. + + \smallskip + + \lstinline{string5 *p} hingegen erwartet einen Zeiger auf ein Array + von 5 \lstinline{char}-Variablen. + + \smallskip + + Es bekommt die Adresse von \lstinline{"Dies"} zugewiesen. + + \smallskip + + Durch das Erhöhen von \lstinline{p} (um 5) zeigt es danach + \emph{zufällig\/} auf das \lstinline{"ist"}. + + Bei nochmaligem Erhöhen zeigt es auf das \lstinline{"in"} von \lstinline{"ein"}. + + \smallskip + + (Auch ohne Optimierung werden die Strings \lstinline{"ist"}, \lstinline{"ein"} + und \lstinline{"Test"}\\ + u.\,U.\ wegoptimiert.) + +\end{frame} + +\iffalse + +\nosectionnonumber{\large\bf Übungsaufgabe: Verkettete Listen} + +\begin{frame} + + \shownosectionnonumber + + \begin{enumerate}[\quad(a)] + \item + Schreiben Sie eine Funktion, die eine verkettete Liste\\ + in die umgekehrte Reihenfolge bringt. + \item + Schreiben Sie eine Funktion, die eine verkettete Liste\\ + in eine doppelt verkettete Liste umwandelt. + \item + Wieviel Rechenzeit (Landau-Symbol) benötigen Ihre Funktionen? + \item + Wieviel Speicherplatz (Landau-Symbol) benötigen Ihre Funktionen? + \end{enumerate} + +\end{frame} + +\fi + +\section{Langzahl-Arithmetik} + +\begin{frame} + + \showsection + + Problem: Rechnen mit ganzen Zahlen, die größer sind als das,\\ + was der Rechner normalerweise verarbeiten kann + + \bigskip + + {\large\textbf{Aufgabe: Addition langer Zahlen}\par} + \smallskip + \begin{itemize} + \item[(a)] + Überlegen Sie sich eine Datenstruktur, um eine lange Zahl zu speichern. + \item[(b)] + Schreiben Sie eine Funktion, die zwei lange Zahlen addiert. + \end{itemize} + +\end{frame} + +\begin{frame} + + \showsection + + Problem: Rechnen mit ganzen Zahlen, die größer sind als das,\\ + was der Rechner normalerweise verarbeiten kann + + \medskip + + \begin{itemize} + \item + Grundrechenarten (einschließlich "`modulo"'):\\ + "`schriftlich"' rechnen + \item + \href{https://de.wikipedia.org/wiki/Binäre_Exponentiation}% + {binäre Exponentiation}:\\ + Basis fortlaufend quadrieren, ggf.\ damit multiplizieren\\ + Beispiel: $x^9 = ((x^2)^2)^2 \cdot x$ + \item + Suche nach $d$ mit $d\cdot e~\text{mod}~N = 1$:\\ + \href{https://de.wikipedia.org/wiki/Erweiterter_euklidischer_Algorithmus}% + {erweiterter euklidischer Algorithmus} + \smallskip + \arrowitem + RSA + \end{itemize} + +\end{frame} + +\section{Kryptographie} +\subsectionnonumber{\boldmath 4.$(x^2 - 1)$\quad Der Herr der Ringe: Manchmal ist $1 + 1 = 0$.} +\subsubsectionnonumber{\boldmath 4.$(x^2 - 1).x$\quad Motivation} + +\begin{frame} + + \showsection + \pause + \showsubsectionnonumber + \pause + \showsubsubsectionnonumber + + Man kann auch mit sehr merkwürdigen Objekten\\ + wie mit "`ganz normalen"' Zahlen rechnen. + + \pause + \bigskip + + Anwendungen: + \begin{itemize} + \item Funktionsweise von Computern (\textarrow\ Rechnertechnik) + \item Fehlererkennung + \item Fehlerkorrektur + \item Verschlüsselung + \item Digitale Signaturen + \end{itemize} + +\end{frame} + +\subsubsectionnonumber{\boldmath 4.$(x^2 - 1).(x + 1)$\quad Gruppen} + +\begin{frame} + + \showsection + \showsubsectionnonumber + \showsubsubsectionnonumber + + \textbf{Definition:} + Sei $G$ eine Menge, $*$ eine Verknüpfung auf $G$. + Wenn + \begin{itemize} + \item + $\forall a, b, c \in G$: $(a * b) * c = a * (b * c)$ \quad (Assoziativgesetz), + \item + $\exists e \in G$: $\forall a \in G$: $a * e = e * a = a$ \quad (neutrales Element), + \item + $\forall a \in G$: $\exists a^{-1} \in G$: $a * a^{-1} = a^{-1} * a = e$ \quad (inverses Element), + \end{itemize} + dann heißt $(G,*)$ eine \newterm{Gruppe}. + + \pause + \bigskip + + \textbf{Definition:} + Sei $(G,*)$ eine Gruppe. + Wenn zusätzlich + \begin{itemize} + \item + $\forall a, b \in G$: $a * b = b * a$ \quad (Kommutativgesetz), + \end{itemize} + dann heißt $(G,*)$ eine \newterm{kommutative Gruppe}. + +\end{frame} + +\subsubsectionnonumber{\boldmath 4.$(x^2 - 1).(x + 2)$\quad Ringe} + +\begin{frame} + +% \showsection + \showsubsectionnonumber + \showsubsubsectionnonumber + + \textbf{Definition:} + Sei $R$ eine Menge; seien $+$ und $\cdot$ Verknüpfungen auf $R$. + Wenn + \begin{itemize} + \item + $(R,+)$ eine kommutative Gruppe ist, + \item + $\forall a, b, c \in R$: $(a \cdot b) \cdot c = a \cdot (b \cdot c)$ \quad (Assoziativgesetz), + \item + $\forall a, b, c \in R$: $(a + b)\cdot c = a\cdot c + b\cdot c$ + und $a\cdot(b + c) = a\cdot b + a\cdot c$ \quad (Distributivgesetze), + \end{itemize} + dann heißt $(R,+,\cdot)$ ein \newterm{Ring}. + + \pause + \bigskip + + \textbf{Definition:} + Sei $(R,+,\cdot)$ ein Ring. + Wenn zusätzlich + \begin{itemize} + \item + $\forall a, b \in R$: $a \cdot b = b \cdot a$ \quad (Kommutativgesetz), + \end{itemize} + dann heißt $(R,+,\cdot)$ ein \newterm{kommutativer Ring}. + + \pause + \bigskip + + \textbf{Definition:} + Sei $(R,+,\cdot)$ ein (kommutativer) Ring. + Wenn zusätzlich + \begin{itemize} + \item + ein $e \in R$ existiert, so daß für alle $a \in R$ gilt: $a \cdot e = e \cdot a = a$\\ + (neutrales Element), + \end{itemize} + dann heißt $(R,+,\cdot)$ ein \newterm{(kommutativer) Ring mit 1}. + + \vspace*{-1cm} + +\end{frame} + +\subsubsectionnonumber{\boldmath 4.$(x^2 - 1).(x + 3)$\quad Körper} + +\begin{frame} + +% \showsection + \showsubsectionnonumber + \showsubsubsectionnonumber + + \textbf{Definition:} + Sei $K$ eine Menge; seien $+$ und $\cdot$ Verknüpfungen auf $K$. + Wenn + \begin{itemize} + \item + $(K,+,\cdot)$ ein Ring mit 1 ist und + \item + $(K \backslash \{0\},\cdot)$ eine kommutative Gruppe ist, + \end{itemize} + dann heißt $(K,+,\cdot)$ ein \newterm{Körper}. + +\end{frame} + +\end{document} diff --git a/20240411/landau-symbols-2.pdf b/20240411/landau-symbols-2.pdf new file mode 120000 index 0000000000000000000000000000000000000000..6b458b6efd8e274824a6dfcaabc4b9c27d196dc4 --- /dev/null +++ b/20240411/landau-symbols-2.pdf @@ -0,0 +1 @@ +../common/landau-symbols-2.pdf \ No newline at end of file diff --git a/20240411/landau-symbols-3.pdf b/20240411/landau-symbols-3.pdf new file mode 120000 index 0000000000000000000000000000000000000000..46efa409b35ff5df763c744a423599cba515d886 --- /dev/null +++ b/20240411/landau-symbols-3.pdf @@ -0,0 +1 @@ +../common/landau-symbols-3.pdf \ No newline at end of file diff --git a/20240411/landau-symbols.pdf b/20240411/landau-symbols.pdf new file mode 120000 index 0000000000000000000000000000000000000000..ca145425bf07439c680632aa0663f84be601a565 --- /dev/null +++ b/20240411/landau-symbols.pdf @@ -0,0 +1 @@ +../common/landau-symbols.pdf \ No newline at end of file diff --git a/20240411/logo-hochschule-bochum-cvh-text.pdf b/20240411/logo-hochschule-bochum-cvh-text.pdf new file mode 120000 index 0000000000000000000000000000000000000000..a05946126bc0ce6a2818740da2893f59eb0c659c --- /dev/null +++ b/20240411/logo-hochschule-bochum-cvh-text.pdf @@ -0,0 +1 @@ +../common/logo-hochschule-bochum-cvh-text.pdf \ No newline at end of file diff --git a/20240411/logo-hochschule-bochum.pdf b/20240411/logo-hochschule-bochum.pdf new file mode 120000 index 0000000000000000000000000000000000000000..b6b9491e370e499c9276918182cdb82cb311bcd1 --- /dev/null +++ b/20240411/logo-hochschule-bochum.pdf @@ -0,0 +1 @@ +../common/logo-hochschule-bochum.pdf \ No newline at end of file diff --git a/20240411/pgslides.sty b/20240411/pgslides.sty new file mode 120000 index 0000000000000000000000000000000000000000..5be1416f4216f076aa268901f52a15d775e43f64 --- /dev/null +++ b/20240411/pgslides.sty @@ -0,0 +1 @@ +../common/pgslides.sty \ No newline at end of file