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.

322 lines
9.7 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
  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. {\bf Solution}: Maintain three pointers following each other: current, next, and
  82. previous. The first pointer is one element ahead of the second. Reverse each pointer
  83. as you you.
  84. \fi
  85. \subsection{Preorder Tree Traversal}
  86. Consider the following tree and state the \emph{preorder} and \emph{inorder} traversal.
  87. \begin{verbatim}
  88. 5
  89. / \
  90. 7 4
  91. \ / \
  92. 1 2 9
  93. \end{verbatim}
  94. Which data structure do you need to implement such a traversal?
  95. \ifdefined\loesung
  96. {\bf Solution}: Preorder: 5, 7, 1, 4, 2, 9; Inorder: 7, 1, 5, 2, 4, 9.
  97. Such traversals are implemented using a stack (explicitly or implicitly using
  98. a recursive traversal)
  99. \fi
  100. \subsection{Breadth-First-Search}
  101. What is the BFS traversal of the tree above? Which data structure is needed to implement
  102. such a traversal?
  103. \ifdefined\loesung
  104. {\bf Solution}: BFS: 5, 7, 4, 1, 2, 9. You need a queue to implement BFS.
  105. \fi
  106. \section{Networking}
  107. \section{Regular Expressions and Shells}
  108. \section{Databases}
  109. %------------------------------------------------------------------------------
  110. \subsection{SQL statements}
  111. %------------------------------------------------------------------------------
  112. Write down the results of the following SQL statements on table T.
  113. \begin{quote}
  114. \begin{tabular}[t]{l|l|l|l}
  115. T & A & B & C \\
  116. \hline
  117. & 1 & blue & 10 \\
  118. & 2 & blue & 40 \\
  119. & 3 & pink & 30 \\
  120. & 4 & orange & 10 \\
  121. & 5 & orange & 20 \\
  122. & 6 & orange & 50 \\
  123. & 7 & orange & 50 \\
  124. & 8 & black & 50 \\
  125. & 9 & black & 40 \\
  126. & 10 & violet & 10 \\
  127. & 11 & violet & 20 \\
  128. & 12 & violet & 10 \\
  129. \end{tabular}
  130. \end{quote}
  131. \begin{description}
  132. \item[a.)] {\tt SELECT B, COUNT(*) FROM T GROUP BY B HAVING SUM(C)<=40}
  133. \begin{quote}
  134. \begin{tabular}[t]{|p{2.5cm}|p{2.5cm}|}
  135. \hline
  136. B & COUNT(*) \\
  137. \hline
  138. \hline
  139. \ifdefined\loesung
  140. \textcolor{red}{pink} & \textcolor{red}{1} \\[0.3cm]
  141. \hline
  142. \textcolor{red}{violet} & \textcolor{red}{3} \\[0.3cm]
  143. \hline
  144. \textcolor{red}{} & \textcolor{red}{} \\[0.3cm]
  145. \hline
  146. \textcolor{red}{} & \textcolor{red}{} \\[0.3cm]
  147. \else
  148. & \\[0.3cm]
  149. \hline
  150. & \\[0.3cm]
  151. \hline
  152. & \\[0.3cm]
  153. \hline
  154. & \\[0.3cm]
  155. \fi
  156. \hline
  157. \end{tabular}
  158. \end{quote}
  159. \item[b.)] {\tt SELECT B, COUNT(*) FROM T WHERE C>35 \\GROUP BY B HAVING COUNT(*)>=2}
  160. \begin{quote}
  161. \begin{tabular}[t]{|p{2.5cm}|p{2.5cm}|}
  162. \hline
  163. B & COUNT(*) \\
  164. \hline
  165. \hline
  166. \ifdefined\loesung
  167. \textcolor{red}{orange} & \textcolor{red}{2} \\[0.3cm]
  168. \hline
  169. \textcolor{red}{black} & \textcolor{red}{2} \\[0.3cm]
  170. \hline
  171. \textcolor{red}{} & \textcolor{red}{} \\[0.3cm]
  172. \hline
  173. \textcolor{red}{} & \textcolor{red}{} \\[0.3cm]
  174. \else
  175. & \\[0.3cm]
  176. \hline
  177. & \\[0.3cm]
  178. \hline
  179. & \\[0.3cm]
  180. \hline
  181. & \\[0.3cm]
  182. \fi
  183. \hline
  184. \end{tabular}
  185. \end{quote}
  186. \end{description}
  187. %------------------------------------------------------------------------------
  188. \subsection{Constraints \& Integrity}
  189. %------------------------------------------------------------------------------
  190. The following table definition with integrity constraints are given.
  191. \begin{quote}
  192. {\tt
  193. \begin{tabbing}
  194. CREATE TABLE T1 (\=A INT, B INT, C INT,\\
  195. \>CONSTRAINT T1\_PS PRIMARY KEY (A,B),\\
  196. \>CONSTRAINT T1\_SK UNIQUE (C));\\
  197. \\
  198. CREATE TABLE T2 (A INT, B INT, C INT, D INT, E INT,\\
  199. \>CONSTRAINT T2\_PS PRIMARY KEY (A),\\
  200. \>CONSTRAINT T2\_FS1 FOREIGN KEY (B,C) REFERENCES T1(A,B),\\
  201. \>CONSTRAINT T2\_FS2 FOREIGN KEY (D) REFERENCES T1(C),\\
  202. \>CONSTRAINT T2\_E\_NN CHECK (E IS NOT NULL),\\
  203. \>CONSTRAINT T2\_E\_13 CHECK (E BETWEEN 1 AND 3)); \\
  204. \end{tabbing}}
  205. \end{quote}
  206. The table T1 and T2 contain the following tuples. NULL values are indicated by a hyphen (-).
  207. \begin{quote}
  208. \begin{tabular}[t]{l|l|l|l}
  209. T1 & A & B & C \\
  210. \hline
  211. & 1 & 1 & 5 \\
  212. & 2 & 2 & 10 \\
  213. & 3 & 3 & 15 \\
  214. & 4 & 4 & 20 \\
  215. & 5 & 5 & 25 \\
  216. \end{tabular}
  217. \hspace{2cm}
  218. \begin{tabular}[t]{l|l|l|l|l|l}
  219. T2 & A & B & C & D & E\\
  220. \hline
  221. & 100 & - & - & 15 & 1 \\
  222. & 101 & 2 & 2 & 25 & 2 \\
  223. & 102 & 2 & 2 & - & 3 \\
  224. & 103 & 3 & 3 & 10 & 3 \\
  225. & 104 & 3 & 3 & 10 & 3 \\
  226. \end{tabular}
  227. \end{quote}
  228. 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.
  229. \begin{tabular}[t]{|l|l|l|}
  230. \hline
  231. Nr. & INSERT-statement & Violated constraint \\[0.3cm]
  232. \hline
  233. 1 & {\tt INSERT INTO T1 VALUES (1, 2, 5)} & \ifdefined\loesung \textcolor{red}{T1\_SK} \fi \\[0.3cm]
  234. \hline
  235. 2 & {\tt INSERT INTO T1 VALUES (1, 2, 30)} & \ifdefined\loesung \textcolor{red}{none} \fi \\[0.3cm]
  236. \hline
  237. 3 & {\tt INSERT INTO T1 VALUES (1, 1, 50)} & \ifdefined\loesung \textcolor{red}{T1\_PS} \fi \\[0.3cm]
  238. \hline
  239. 4 & {\tt INSERT INTO T1 VALUES (1, NULL, NULL)} & \ifdefined\loesung \textcolor{red}{T1\_PS} \fi \\[0.3cm]
  240. \hline
  241. 5 & {\tt INSERT INTO T2 VALUES (117, 2, 2, 5, 5)} & \ifdefined\loesung \textcolor{red}{T2\_E\_13} \fi \\[0.3cm]
  242. \hline
  243. 6 & {\tt INSERT INTO T2 VALUES (109, 3, 1, 10, 3)} & \ifdefined\loesung \textcolor{red}{T2\_FS1} \fi \\[0.3cm]
  244. \hline
  245. 7 & {\tt INSERT INTO T2 VALUES (103, 1, 1, 20, 2)} & \ifdefined\loesung \textcolor{red}{T2\_PS} \fi \\[0.3cm]
  246. \hline
  247. 8 & {\tt INSERT INTO T2 VALUES (110, 4, 4, 35, 1)} & \ifdefined\loesung \textcolor{red}{T2\_FS2} \fi \\[0.3cm]
  248. \hline
  249. \end{tabular}
  250. %------------------------------------------------------------------------------
  251. \subsection{Relations \& DDL-statements}
  252. %------------------------------------------------------------------------------
  253. The following tables and DDL-statements are given. Please note: an exam with a grade other than 5.0 is passed.
  254. \begin{figure}[htb]
  255. \begin{minipage}{0.30\linewidth}
  256. \includegraphics[width=38mm]{images/task3-chen.pdf}
  257. \end{minipage}
  258. %\hfill
  259. \begin{minipage}{0.55\linewidth}
  260. \scriptsize\lstinputlisting[numbers=none]{queries/task3-ddl.sql}
  261. \end{minipage}
  262. \end{figure}
  263. \begin{description}
  264. \item[a.)] What is defined in the table {\tt STUDENT}?
  265. \ifdefined\loesung \textcolor{red}{
  266. \begin{itemize}
  267. \item the student's Id is the primary key
  268. \item a student's Id have to be between 100000 and 999999
  269. \item the GENDER column is restricted to 'm' for male and 'f' for female
  270. \end{itemize}}\else \vfill \fi
  271. \item[b.)] What is defined in the table {\tt EXAM}?
  272. \ifdefined\loesung \textcolor{red}{
  273. \begin{itemize}
  274. \item the primary key is composed of the student's Id, the attempt and the course name
  275. \item an exam can be taken three times
  276. \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
  277. \item the referenced student Id must exist in the {\tt STUDENT} table ({\tt FOREIGN KEY})
  278. \item the deletion of a student will also delete all associated exams ({\tt ON DELETE CASCADE})
  279. \end{itemize}}\else \vfill \fi
  280. \item[c.)] Define a SQL query to find students (student's Id, firstname, lastname and course) who failed in the third attempt?
  281. \begin{quote}
  282. \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
  283. \end{quote}
  284. \item[d.)] Define a SQL query to report the average attempts for male and female students?
  285. \begin{quote}
  286. \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
  287. \end{quote}
  288. \end{description}
  289. %------------------------------------------------------------------------------
  290. \end{document}
  291. %------------------------------------------------------------------------------