From 1180e009a2f8c100f54449fe9c507a08a215b103 Mon Sep 17 00:00:00 2001 From: Joerg Kreiker Date: Tue, 5 Jun 2018 21:42:59 +0200 Subject: [PATCH] added programming exercise --- gsd-questions.tex | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/gsd-questions.tex b/gsd-questions.tex index 700771d..15aa824 100755 --- a/gsd-questions.tex +++ b/gsd-questions.tex @@ -39,6 +39,52 @@ %\def\loesung{} \section{Programming} +\subsection{Row Vectors} +Consider an $n\times m$ matrix. Calculate the absolute value for each row vector of the matrix in a programming language of your choice. Example: +$$ +\left(\begin{array}{cc} + 2 & 2 \\ 4 & 4 \\ 6 & 5 +\end{array}\right) +\qquad \Rightarrow \qquad\texttt{calcAbsRowVector}\qquad \Rightarrow \qquad +\left(\begin{array}{c} + 2.82 \\ 5.65 \\ 7.81 +\end{array}\right) +$$ +\ifdefined\loesung +\begin{verbatim} +Musterloesung here +\end{verbatim} +\fi + +\subsection{Merging and Sorting} +Let $A$ and $B$ be two arrays of $n$ (unsorted) integer entries each. Write +a function that merges both arrays into a \emph{sorted} array of $2\dot n$ +entries. Example: +$$ +\begin{array}{lcl} + A & = & [2, 7, 5, 34]\\ + B & = & [3, 48, 4, 72]\\ + \hline + C & = & [2, 3, 4, 5, 7, 34, 48, 72]\\ +\end{array} +$$ + +\ifdefined\loesung +\begin{verbatim} +Musterloesung here +\end{verbatim} +\fi + +\subsection{Recursion} + +Consider a herd of cows. Write a \emph{recursive} function to calculate the +sum of all legs. Use addition only (no multiplication allowed). + +\ifdefined\loesung +\begin{verbatim} +Musterloesung here +\end{verbatim} +\fi \section{Algorithms and Data Structures}