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.

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