Compare commits

...

9 Commits

  1. 181
      gsd-questions.tex
  2. BIN
      images/logo.jpg
  3. BIN
      images/mac-address.png
  4. BIN
      images/tcp-handshake-and-flowcontrol.png
  5. 111
      todten/GSDSolution.java

181
gsd-questions.tex

@ -1,10 +1,15 @@
\documentclass[a4paper,11pt]{article}
\documentclass[a4paper,10pt]{article}
\usepackage{a4wide}
\usepackage{german}
\usepackage{graphicx}
\usepackage{versions}
\usepackage{amsmath}
\usepackage{color}
\usepackage{colortbl}
\usepackage{anysize}
\usepackage{enumerate}
\usepackage{verbatim}
\usepackage[utf8]{inputenc}
\usepackage{amssymb}
@ -16,13 +21,163 @@
\setlength{\parindent}{0mm}
\begin{document}
\vspace*{-3cm}
\hspace*{-1cm}\begin{tabular}{p{.55\linewidth}p{.55\linewidth}}
\begin{minipage}{\linewidth}
{\bf Global Software Development} \\
Kreiker, Pape, Rieger, Todtenh"ofer\\
Summer Term 2018\\\\
\today\\
\end{minipage}
&
\includegraphics[width=\linewidth]{images/logo}
\end{tabular}
\begin{center}
{\Large\bf GSD Interview Questions}\\
\end{center}
%\def\loesung{}
\textsc{Hochschule Fulda}{\small\hfill GSD Database \& SQL questionnaire}\\
{\small Fachbereich Angewandte Informatik{\small\hfill SS 18}\\
Dipl.-Inf. Christian Pape}\\
\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)
$$
\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}
$$
\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
\subsection{Loesung}
\verbatiminput{todten/GSDSolution.java}
\fi
\section{Algorithms and Data Structures}
\subsection{In-situ List Reversal}
Describe an algorithm to reverse a singly-linked list that \emph{does not}
copy any memory cells.
\ifdefined\loesung
\textcolor{red}{
{\bf Solution}: Maintain three pointers following each other: current, next, and
previous. The first pointer is one element ahead of the second. Reverse each pointer
as you you.}
\fi
\subsection{Preorder Tree Traversal}
Consider the following tree and state the \emph{preorder} and \emph{inorder} traversal.
\begin{verbatim}
5
/ \
7 4
\ / \
1 2 9
\end{verbatim}
Which data structure do you need to implement such a traversal?
\ifdefined\loesung
\textcolor{red}{
{\bf Solution}: Preorder: 5, 7, 1, 4, 2, 9; Inorder: 7, 1, 5, 2, 4, 9.
Such traversals are implemented using a stack (explicitly or implicitly using
a recursive traversal)}
\fi
\subsection{Breadth-First-Search}
What is the BFS traversal of the tree above? Which data structure is needed to implement
such a traversal?
\ifdefined\loesung
\textcolor{red}{
{\bf Solution}: BFS: 5, 7, 4, 1, 2, 9. You need a queue to implement BFS.}
\fi
\section{Networking}
\subsection{Protocol Stacks}
Explain the major differences between the network protocols UDP, TCP and IP.
\ifdefined\loesung
\textcolor{red}{
{\bf Solution}: UDP is connectionless, offers no error correction etc., data is sent directly without handshake, typically used for real-time protocols. TCP is connection-oriented, offers error correction, flow control (also congestion control), bidirectional reliable data transfer. IP is on a different layer (Layer 3 / network layer) compared to TCP and UDP (Layer 4 / transport layer), IP is connectionless transports datagrams between endpoints, supports routing etc.}
\fi
\subsection{TCP Characteristics}
Fill the gaps with appropriate values for the corresponding TCP header fields:
\begin{figure}[htb]
\includegraphics[width=0.9\columnwidth]{images/tcp-handshake-and-flowcontrol.png}
\end{figure}
\ifdefined\loesung
\textcolor{red}{
{\bf Solution}: 2: Flags = SYN+ACK, 3: Flags = ACK, 5: ACK = sa+900, Data-Length = 400 (according to ACK in 7), 6: SEQ = sa+900, Data-Length = 100 (due to limit in (Receive) Window Size), 7: sa+1000.}
\fi
\subsection{Network Addresses}
Insert the Layer 2 and Layer 3 addresses used the following transfer from Computer A to Computer B. How many IP addresses can exist in the subnet Computer B is placed in? What is the network address of this subnet?
\begin{figure}[htb]
\includegraphics[width=0.9\columnwidth]{images/mac-address.png}
\end{figure}
\ifdefined\loesung
\textcolor{red}{
{\bf Solution}: Source IP: 1.1.1.10 (not 1.1.1.10/24), Destination IP: 2.2.15.100 (not 2.2.15.100/21), Source MAC: 11:22:33:44:55:66, Destination MAC: aa:bb:cc:dd:ee:ff (not 33:44:55:66:77:88). Number of hosts in /21 IPv4 subnet = 2046 ($2^{32-21}-2$). Network address of the IP subnet of Computer B: 2.2.8.0/21.}
\fi
\section{Regular Expressions and Shells}
\subsection{Regular Expression}
Explain the following regex:
\begin{verbatim}
^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$
\end{verbatim}
\ifdefined\loesung
\textcolor{red}{
{\bf Solution}: This regex describes well-formatted IPv4 addresses. Number of repetitions
given in braces, Question mark for optional choices, brackets denote ranges.}
\fi
\subsection{Extract Lines}
Write a shell command to extract lines number 101-110 from a file {\tt a.txt} and
output them (numerically sorted) to file {\tt b.txt}.
\ifdefined\loesung\textcolor{red}{
{\bf Solution}: {\tt cat a.txt | head -110 | tail -10 | sort -n > b.txt}}
\fi
\subsection{Large Files}
Write a shell command to find the file with the most number of lines in
the current directory.
\ifdefined\loesung\textcolor{red}{
{\bf Solution}: {\tt wc -l * | sort -nr} is key. One might get rid of the \emph{total} line count
and access the file name only. Optional.}
\fi
\section{Databases}
%------------------------------------------------------------------------------
\textbf{Task 1 (SQL statements):}\\
\subsection{SQL statements}
%------------------------------------------------------------------------------
Write down the results of the following SQL statements on table T.
\begin{quote}
@ -102,13 +257,8 @@ T & A & B & C \\
\end{quote}
\end{description}
\pagebreak
\textsc{Hochschule Fulda}{\small\hfill GSD Database \& SQL questionnaire}\\
{\small Fachbereich Angewandte Informatik{\small\hfill SS 18}\\
Dipl.-Inf. Christian Pape}\\
%------------------------------------------------------------------------------
\textbf{Task 2 (constraints \& integrity):}\\
\subsection{Constraints \& Integrity}
%------------------------------------------------------------------------------
The following table definition with integrity constraints are given.
\begin{quote}
@ -175,13 +325,8 @@ Nr. & INSERT-statement & Violated constraint \\[0.3cm]
\hline
\end{tabular}
\pagebreak
\textsc{Hochschule Fulda}{\small\hfill GSD Database \& SQL questionnaire}\\
{\small Fachbereich Angewandte Informatik{\small\hfill SS 18}\\
Dipl.-Inf. Christian Pape}\\
%------------------------------------------------------------------------------
\textbf{Task 3 (relations \& DDL-statements):}\\
\subsection{Relations \& DDL-statements}
%------------------------------------------------------------------------------
The following tables and DDL-statements are given. Please note: an exam with a grade other than 5.0 is passed.
\begin{figure}[htb]
@ -194,8 +339,6 @@ The following tables and DDL-statements are given. Please note: an exam with a g
\end{minipage}
\end{figure}
\begin{description}
\item[a.)] What is defined in the table {\tt STUDENT}?
\ifdefined\loesung \textcolor{red}{

BIN
images/logo.jpg

After

Width: 2362  |  Height: 591  |  Size: 232 KiB

BIN
images/mac-address.png

After

Width: 1444  |  Height: 471  |  Size: 145 KiB

BIN
images/tcp-handshake-and-flowcontrol.png

After

Width: 1376  |  Height: 672  |  Size: 76 KiB

111
todten/GSDSolution.java

@ -0,0 +1,111 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package gsdsolution;
/**
*
* @author todten
*/
import java.math.*;
import java.util.*;
public class GSDSolution {
/* Main Program */
public static void main(String[] args) {
int someCows = 10;
System.out.println(someCows + " cows have " + countLegs(someCows) + " legs \n");
System.out.println("Calculate Row Vector");
calcAbsRowVector(inputMatrix);
System.out.println("Merge and Sort Arrays");
mergeAndSortArrays(input1, input2);
}
/* Third Exercise */
public static int countLegs(int cows) {
if (cows == 0) {
return 0;
} else {
return 4 + countLegs(cows - 1);
}
}
/* First Exercise */
static int[][] inputMatrix = new int[][]{
{2, 2},
{4, 4},
{6, 5}};
public static double[] calcAbsRowVector(int[][] aMatrix) {
double[] result = new double[aMatrix.length];
double temp = 0.0;
for (int i = 0; i < aMatrix.length; i++) {
for (int j = 0; j < aMatrix[i].length; j++) {
temp = temp + Math.pow(aMatrix[i][j], 2);
//System.out.println(" I = " + i + " J = " + j + " Temp = " + temp);
}
result[i] = Math.sqrt(temp);
temp = 0.0;
//System.out.println(" Result at I " + i + " Result " + result[i]);
}
return result;
}
/* Second Exercise */
static int[] input1 = new int[]{2, 7, 5, 34};
static int[] input2 = new int[]{3, 48, 4, 72};
public static int[] mergeAndSortArrays(int[] firstArray, int[] secondArray) {
int[] resultArray = new int[firstArray.length * 2];
/* OK, both Arrays are the same size */
int offset = firstArray.length;
for (int i = 0; i < firstArray.length; i++) {
resultArray[i] = firstArray[i];
}
for (int i = 0; i < secondArray.length; i++) {
resultArray[i + offset] = secondArray[i];
}
/* Just for debugging */
System.out.println("Result Array " + Arrays.toString(resultArray));
/*
* Die haeufigste Antwort wird die Verwendung der build - in Funktion
* von Java zum Sortieren von Arrays sein
*/
Arrays.sort(resultArray);
/*
* Dann nachfragen und den Bewerber das Array manuell mit einem
* Algorithmus seiner Wahl (z.B. Quicksort oder einfache Maximumssuche)
* sortieren lassen
*/
/* Just for debugging */
System.out.println("Sorted Result Array " + Arrays.toString(resultArray));
return resultArray;
}
}
Loading…
Cancel
Save