Browse Source

added programming exercise

master
Joerg Kreiker 3 years ago
parent
commit
1180e009a2
  1. 46
      gsd-questions.tex

46
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}

Loading…
Cancel
Save