| 1 |
% This file is public domain |
| 2 |
% |
| 3 |
% These problems are a mixture of essay-style and questions with |
| 4 |
% answers. One of these problems requires the tikz package |
| 5 |
|
| 6 |
\newproblem*{oop}{Describe what is meant by object-oriented |
| 7 |
programming.} |
| 8 |
|
| 9 |
\begin{defproblem}{inheritance} |
| 10 |
Describe what is meant by the term \emph{inheritance} in |
| 11 |
object-oriented programming. Use examples. |
| 12 |
\end{defproblem} |
| 13 |
|
| 14 |
\begin{defproblem}{weightedcoin}% |
| 15 |
\begin{onlyproblem} |
| 16 |
A coin is weighted so that heads is four times as likely |
| 17 |
as tails. Find the probability that: |
| 18 |
\begin{textenum} |
| 19 |
\item tails appears, |
| 20 |
\item heads appears |
| 21 |
\end{textenum}% |
| 22 |
\end{onlyproblem}% |
| 23 |
\begin{onlysolution} |
| 24 |
Let $p=P(T)$, then $P(H)=4p$. We require $P(H)+P(T)=1$, |
| 25 |
so $4p+p=1$, hence $p=\frac{1}{5}$. Therefore: |
| 26 |
\begin{textenum} |
| 27 |
\item $P(T)=\frac{1}{5}$, |
| 28 |
\item $P(H)=\frac{4}{5}$ |
| 29 |
\end{textenum} |
| 30 |
\end{onlysolution} |
| 31 |
\end{defproblem} |
| 32 |
|
| 33 |
\begin{defproblem}{validprobspaces} |
| 34 |
\begin{onlyproblem}% |
| 35 |
Under which of the following functions does |
| 36 |
$S=\{a_1,a_2\}$ become a probability space? |
| 37 |
\par |
| 38 |
\begin{textenum} |
| 39 |
\begin{tabular}{ll} |
| 40 |
\item $P(a_1)=\frac{1}{3}$, $P(a_2)=\frac{1}{2}$ |
| 41 |
& |
| 42 |
\item\label{validprobspacescorrect1} $P(a_1)=\frac{3}{4}$, |
| 43 |
$P(a_2)=\frac{1}{4}$ |
| 44 |
\\ |
| 45 |
\item\label{validprobspacescorrect2} $P(a_1)=1$, $P(a_2)=0$ |
| 46 |
& |
| 47 |
\item $P(a_1)=\frac{5}{4}$, $P(a_2)=-\frac{1}{4}$ |
| 48 |
\end{tabular} |
| 49 |
\end{textenum} |
| 50 |
\end{onlyproblem}% |
| 51 |
\begin{onlysolution}% |
| 52 |
\ref{validprobspacescorrect1} and \ref{validprobspacescorrect2}% |
| 53 |
\end{onlysolution} |
| 54 |
\end{defproblem} |
| 55 |
|
| 56 |
\begin{defproblem}{digraph} |
| 57 |
\begin{onlyproblem}\label{ex:digraph} |
| 58 |
Identify, if any, the sinks and sources of the digraph shown in Figure~\ref{fig:digraph}. |
| 59 |
|
| 60 |
\begin{figure}[tbh] |
| 61 |
\centering |
| 62 |
\begin{tikzpicture}[every node/.style={draw,circle}] |
| 63 |
\path (0,0) node (A) {$A$} |
| 64 |
(1,0) node (B) {$B$} |
| 65 |
(0,1) node (C) {$C$}; |
| 66 |
\draw[->] (A) -- (B); |
| 67 |
\draw[->] (B) -- (C); |
| 68 |
\draw[->] (A) -- (C); |
| 69 |
\end{tikzpicture} |
| 70 |
\par |
| 71 |
\caption{Digraph for Question~\ref{ex:digraph}} |
| 72 |
\label{fig:digraph} |
| 73 |
\end{figure} |
| 74 |
\end{onlyproblem} |
| 75 |
\begin{onlysolution} |
| 76 |
$A$ is a souce and $C$ is a sink. |
| 77 |
\end{onlysolution} |
| 78 |
\end{defproblem} |