GSD Questions
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

351 lines
11 KiB

7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
  1. \documentclass[a4paper,10pt]{article}
  2. \usepackage{a4wide}
  3. \usepackage{german}
  4. \usepackage{graphicx}
  5. \usepackage{versions}
  6. \usepackage{amsmath}
  7. \usepackage{color}
  8. \usepackage{colortbl}
  9. \usepackage{anysize}
  10. \usepackage{enumerate}
  11. \usepackage[utf8]{inputenc}
  12. \usepackage{amssymb}
  13. \usepackage{amsmath}
  14. \usepackage{tikz}
  15. \usepackage{listings}
  16. \pagestyle{empty}
  17. \setlength{\parindent}{0mm}
  18. \begin{document}
  19. \vspace*{-3cm}
  20. \hspace*{-1cm}\begin{tabular}{p{.55\linewidth}p{.55\linewidth}}
  21. \begin{minipage}{\linewidth}
  22. {\bf Global Software Development} \\
  23. Kreiker, Pape, Rieger, Todtenh"ofer\\
  24. Summer Term 2018\\\\
  25. \today\\
  26. \end{minipage}
  27. &
  28. \includegraphics[width=\linewidth]{images/logo}
  29. \end{tabular}
  30. \begin{center}
  31. {\Large\bf GSD Interview Questions}\\
  32. \end{center}
  33. %\def\loesung{}
  34. \section{Programming}
  35. \subsection{Row Vectors}
  36. 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:
  37. $$
  38. \left(\begin{array}{cc}
  39. 2 & 2 \\ 4 & 4 \\ 6 & 5
  40. \end{array}\right)
  41. \qquad \Rightarrow \qquad\texttt{calcAbsRowVector}\qquad \Rightarrow \qquad
  42. \left(\begin{array}{c}
  43. 2.82 \\ 5.65 \\ 7.81
  44. \end{array}\right)
  45. $$
  46. \ifdefined\loesung
  47. \begin{verbatim}
  48. Musterloesung here
  49. \end{verbatim}
  50. \fi
  51. \subsection{Merging and Sorting}
  52. Let $A$ and $B$ be two arrays of $n$ (unsorted) integer entries each. Write
  53. a function that merges both arrays into a \emph{sorted} array of $2\dot n$
  54. entries. Example:
  55. $$
  56. \begin{array}{lcl}
  57. A & = & [2, 7, 5, 34]\\
  58. B & = & [3, 48, 4, 72]\\
  59. \hline
  60. C & = & [2, 3, 4, 5, 7, 34, 48, 72]\\
  61. \end{array}
  62. $$
  63. \ifdefined\loesung
  64. \begin{verbatim}
  65. Musterloesung here
  66. \end{verbatim}
  67. \fi
  68. \subsection{Recursion}
  69. Consider a herd of cows. Write a \emph{recursive} function to calculate the
  70. sum of all legs. Use addition only (no multiplication allowed).
  71. \ifdefined\loesung
  72. \begin{verbatim}
  73. Musterloesung here
  74. \end{verbatim}
  75. \fi
  76. \section{Algorithms and Data Structures}
  77. \subsection{In-situ List Reversal}
  78. Describe an algorithm to reverse a singly-linked list that \emph{does not}
  79. copy any memory cells.
  80. \ifdefined\loesung
  81. \textcolor{red}{
  82. {\bf Solution}: Maintain three pointers following each other: current, next, and
  83. previous. The first pointer is one element ahead of the second. Reverse each pointer
  84. as you you.}
  85. \fi
  86. \subsection{Preorder Tree Traversal}
  87. Consider the following tree and state the \emph{preorder} and \emph{inorder} traversal.
  88. \begin{verbatim}
  89. 5
  90. / \
  91. 7 4
  92. \ / \
  93. 1 2 9
  94. \end{verbatim}
  95. Which data structure do you need to implement such a traversal?
  96. \ifdefined\loesung
  97. \textcolor{red}{
  98. {\bf Solution}: Preorder: 5, 7, 1, 4, 2, 9; Inorder: 7, 1, 5, 2, 4, 9.
  99. Such traversals are implemented using a stack (explicitly or implicitly using
  100. a recursive traversal)}
  101. \fi
  102. \subsection{Breadth-First-Search}
  103. What is the BFS traversal of the tree above? Which data structure is needed to implement
  104. such a traversal?
  105. \ifdefined\loesung
  106. \textcolor{red}{
  107. {\bf Solution}: BFS: 5, 7, 4, 1, 2, 9. You need a queue to implement BFS.}
  108. \fi
  109. \section{Networking}
  110. \section{Regular Expressions and Shells}
  111. \subsection{Regular Expression}
  112. Explain the following regex:
  113. \begin{verbatim}
  114. ^(?:(?: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]?)$
  115. \end{verbatim}
  116. \ifdefined\loesung
  117. \textcolor{red}{
  118. {\bf Solution}: This regex describes well-formatted IPv4 addresses. Number of repetitions
  119. given in braces, Question mark for optional choices, brackets denote ranges.}
  120. \fi
  121. \subsection{Extract Lines}
  122. Write a shell command to extract lines number 101-110 from a file {\tt a.txt} and
  123. output them (numerically sorted) to file {\tt b.txt}.
  124. \ifdefined\loesung\textcolor{red}{
  125. {\bf Solution}: {\tt cat a.txt | head -110 | tail -10 | sort -n > b.txt}}
  126. \fi
  127. \subsection{Large Files}
  128. Write a shell command to find the file with the most number of lines in
  129. the current directory.
  130. \ifdefined\loesung\textcolor{red}{
  131. {\bf Solution}: {\tt wc -l * | sort -nr} is key. One might get rid of the \emph{total} line count
  132. and access the file name only. Optional.}
  133. \fi
  134. \section{Databases}
  135. %------------------------------------------------------------------------------
  136. \subsection{SQL statements}
  137. %------------------------------------------------------------------------------
  138. Write down the results of the following SQL statements on table T.
  139. \begin{quote}
  140. \begin{tabular}[t]{l|l|l|l}
  141. T & A & B & C \\
  142. \hline
  143. & 1 & blue & 10 \\
  144. & 2 & blue & 40 \\
  145. & 3 & pink & 30 \\
  146. & 4 & orange & 10 \\
  147. & 5 & orange & 20 \\
  148. & 6 & orange & 50 \\
  149. & 7 & orange & 50 \\
  150. & 8 & black & 50 \\
  151. & 9 & black & 40 \\
  152. & 10 & violet & 10 \\
  153. & 11 & violet & 20 \\
  154. & 12 & violet & 10 \\
  155. \end{tabular}
  156. \end{quote}
  157. \begin{description}
  158. \item[a.)] {\tt SELECT B, COUNT(*) FROM T GROUP BY B HAVING SUM(C)<=40}
  159. \begin{quote}
  160. \begin{tabular}[t]{|p{2.5cm}|p{2.5cm}|}
  161. \hline
  162. B & COUNT(*) \\
  163. \hline
  164. \hline
  165. \ifdefined\loesung
  166. \textcolor{red}{pink} & \textcolor{red}{1} \\[0.3cm]
  167. \hline
  168. \textcolor{red}{violet} & \textcolor{red}{3} \\[0.3cm]
  169. \hline
  170. \textcolor{red}{} & \textcolor{red}{} \\[0.3cm]
  171. \hline
  172. \textcolor{red}{} & \textcolor{red}{} \\[0.3cm]
  173. \else
  174. & \\[0.3cm]
  175. \hline
  176. & \\[0.3cm]
  177. \hline
  178. & \\[0.3cm]
  179. \hline
  180. & \\[0.3cm]
  181. \fi
  182. \hline
  183. \end{tabular}
  184. \end{quote}
  185. \item[b.)] {\tt SELECT B, COUNT(*) FROM T WHERE C>35 \\GROUP BY B HAVING COUNT(*)>=2}
  186. \begin{quote}
  187. \begin{tabular}[t]{|p{2.5cm}|p{2.5cm}|}
  188. \hline
  189. B & COUNT(*) \\
  190. \hline
  191. \hline
  192. \ifdefined\loesung
  193. \textcolor{red}{orange} & \textcolor{red}{2} \\[0.3cm]
  194. \hline
  195. \textcolor{red}{black} & \textcolor{red}{2} \\[0.3cm]
  196. \hline
  197. \textcolor{red}{} & \textcolor{red}{} \\[0.3cm]
  198. \hline
  199. \textcolor{red}{} & \textcolor{red}{} \\[0.3cm]
  200. \else
  201. & \\[0.3cm]
  202. \hline
  203. & \\[0.3cm]
  204. \hline
  205. & \\[0.3cm]
  206. \hline
  207. & \\[0.3cm]
  208. \fi
  209. \hline
  210. \end{tabular}
  211. \end{quote}
  212. \end{description}
  213. %------------------------------------------------------------------------------
  214. \subsection{Constraints \& Integrity}
  215. %------------------------------------------------------------------------------
  216. The following table definition with integrity constraints are given.
  217. \begin{quote}
  218. {\tt
  219. \begin{tabbing}
  220. CREATE TABLE T1 (\=A INT, B INT, C INT,\\
  221. \>CONSTRAINT T1\_PS PRIMARY KEY (A,B),\\
  222. \>CONSTRAINT T1\_SK UNIQUE (C));\\
  223. \\
  224. CREATE TABLE T2 (A INT, B INT, C INT, D INT, E INT,\\
  225. \>CONSTRAINT T2\_PS PRIMARY KEY (A),\\
  226. \>CONSTRAINT T2\_FS1 FOREIGN KEY (B,C) REFERENCES T1(A,B),\\
  227. \>CONSTRAINT T2\_FS2 FOREIGN KEY (D) REFERENCES T1(C),\\
  228. \>CONSTRAINT T2\_E\_NN CHECK (E IS NOT NULL),\\
  229. \>CONSTRAINT T2\_E\_13 CHECK (E BETWEEN 1 AND 3)); \\
  230. \end{tabbing}}
  231. \end{quote}
  232. The table T1 and T2 contain the following tuples. NULL values are indicated by a hyphen (-).
  233. \begin{quote}
  234. \begin{tabular}[t]{l|l|l|l}
  235. T1 & A & B & C \\
  236. \hline
  237. & 1 & 1 & 5 \\
  238. & 2 & 2 & 10 \\
  239. & 3 & 3 & 15 \\
  240. & 4 & 4 & 20 \\
  241. & 5 & 5 & 25 \\
  242. \end{tabular}
  243. \hspace{2cm}
  244. \begin{tabular}[t]{l|l|l|l|l|l}
  245. T2 & A & B & C & D & E\\
  246. \hline
  247. & 100 & - & - & 15 & 1 \\
  248. & 101 & 2 & 2 & 25 & 2 \\
  249. & 102 & 2 & 2 & - & 3 \\
  250. & 103 & 3 & 3 & 10 & 3 \\
  251. & 104 & 3 & 3 & 10 & 3 \\
  252. \end{tabular}
  253. \end{quote}
  254. Which of the following INSERT-statements are violating/not violating the defined integrity constraints? Only one integrity constraint will be violated for each statement. Enter the name of the violated integrity constraint or ''none'' if all conditions are met.
  255. \begin{tabular}[t]{|l|l|l|}
  256. \hline
  257. Nr. & INSERT-statement & Violated constraint \\[0.3cm]
  258. \hline
  259. 1 & {\tt INSERT INTO T1 VALUES (1, 2, 5)} & \ifdefined\loesung \textcolor{red}{T1\_SK} \fi \\[0.3cm]
  260. \hline
  261. 2 & {\tt INSERT INTO T1 VALUES (1, 2, 30)} & \ifdefined\loesung \textcolor{red}{none} \fi \\[0.3cm]
  262. \hline
  263. 3 & {\tt INSERT INTO T1 VALUES (1, 1, 50)} & \ifdefined\loesung \textcolor{red}{T1\_PS} \fi \\[0.3cm]
  264. \hline
  265. 4 & {\tt INSERT INTO T1 VALUES (1, NULL, NULL)} & \ifdefined\loesung \textcolor{red}{T1\_PS} \fi \\[0.3cm]
  266. \hline
  267. 5 & {\tt INSERT INTO T2 VALUES (117, 2, 2, 5, 5)} & \ifdefined\loesung \textcolor{red}{T2\_E\_13} \fi \\[0.3cm]
  268. \hline
  269. 6 & {\tt INSERT INTO T2 VALUES (109, 3, 1, 10, 3)} & \ifdefined\loesung \textcolor{red}{T2\_FS1} \fi \\[0.3cm]
  270. \hline
  271. 7 & {\tt INSERT INTO T2 VALUES (103, 1, 1, 20, 2)} & \ifdefined\loesung \textcolor{red}{T2\_PS} \fi \\[0.3cm]
  272. \hline
  273. 8 & {\tt INSERT INTO T2 VALUES (110, 4, 4, 35, 1)} & \ifdefined\loesung \textcolor{red}{T2\_FS2} \fi \\[0.3cm]
  274. \hline
  275. \end{tabular}
  276. %------------------------------------------------------------------------------
  277. \subsection{Relations \& DDL-statements}
  278. %------------------------------------------------------------------------------
  279. The following tables and DDL-statements are given. Please note: an exam with a grade other than 5.0 is passed.
  280. \begin{figure}[htb]
  281. \begin{minipage}{0.30\linewidth}
  282. \includegraphics[width=38mm]{images/task3-chen.pdf}
  283. \end{minipage}
  284. %\hfill
  285. \begin{minipage}{0.55\linewidth}
  286. \scriptsize\lstinputlisting[numbers=none]{queries/task3-ddl.sql}
  287. \end{minipage}
  288. \end{figure}
  289. \begin{description}
  290. \item[a.)] What is defined in the table {\tt STUDENT}?
  291. \ifdefined\loesung \textcolor{red}{
  292. \begin{itemize}
  293. \item the student's Id is the primary key
  294. \item a student's Id have to be between 100000 and 999999
  295. \item the GENDER column is restricted to 'm' for male and 'f' for female
  296. \end{itemize}}\else \vfill \fi
  297. \item[b.)] What is defined in the table {\tt EXAM}?
  298. \ifdefined\loesung \textcolor{red}{
  299. \begin{itemize}
  300. \item the primary key is composed of the student's Id, the attempt and the course name
  301. \item an exam can be taken three times
  302. \item the possible grades for an exam are 1.0, 1.3, 1.7, 2.0, 2.3, 2.7, 3.0, 3.3, 3.7, 4.0, 5.0
  303. \item the referenced student Id must exist in the {\tt STUDENT} table ({\tt FOREIGN KEY})
  304. \item the deletion of a student will also delete all associated exams ({\tt ON DELETE CASCADE})
  305. \end{itemize}}\else \vfill \fi
  306. \item[c.)] Define a SQL query to find students (student's Id, firstname, lastname and course) who failed in the third attempt?
  307. \begin{quote}
  308. \ifdefined\loesung \textcolor{red}{\tt SELECT S.STUDENT\_ID, S.LASTNAME, E.COURSE FROM STUDENT S, EXAM E \\ WHERE S.STUDENT\_ID=E.STUDENT\_ID AND ATTEMPT=3 AND GRADE=5}\else \vfill \fi
  309. \end{quote}
  310. \item[d.)] Define a SQL query to report the average attempts for male and female students?
  311. \begin{quote}
  312. \ifdefined\loesung \textcolor{red}{\tt SELECT S.GENDER, AVG(ATTEMPT) FROM STUDENT S, EXAM E \\ WHERE S.STUDENT\_ID=E.STUDENT\_ID AND NOT GRADE=5 GROUP BY S.GENDER}\else \vfill \fi
  313. \end{quote}
  314. \end{description}
  315. %------------------------------------------------------------------------------
  316. \end{document}
  317. %------------------------------------------------------------------------------