Browse Source

regex questions added

master
Joerg Kreiker 7 years ago
parent
commit
91c9d031c9
  1. 35
      gsd-questions.tex

35
gsd-questions.tex

@ -93,9 +93,10 @@ 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.
as you you.}
\fi
\subsection{Preorder Tree Traversal}
@ -109,21 +110,49 @@ Consider the following tree and state the \emph{preorder} and \emph{inorder} tra
\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)
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
{\bf Solution}: BFS: 5, 7, 4, 1, 2, 9. You need a queue to implement BFS.
\textcolor{red}{
{\bf Solution}: BFS: 5, 7, 4, 1, 2, 9. You need a queue to implement BFS.}
\fi
\section{Networking}
\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}
%------------------------------------------------------------------------------

Loading…
Cancel
Save