\documentstyle[11pt,zed-csp]{article}

\oddsidemargin -0.1in
\evensidemargin -0.1in
\topmargin -0.5in
\textwidth 6.5in
\textheight 9.5in
\parindent 0.25in
\parskip 0.0in
\pagestyle{empty}
\renewcommand{\labelenumiii}{(\roman{enumiii})}


\begin{document}


\begin{center} OLLSCOIL NA h\'{E}IREANN GAILLIMH

\vspace{0.1in}
NATIONAL UNIVERSITY OF IRELAND GALWAY

\vspace{0.15in}
{ ---------------------------------------------  }

SEMESTER II\\
SUMMER EXAMINATIONS 2000

{ ---------------------------------------------  }

Second University Examination in Arts

\vspace{0.15in}
{\bf PROGRAMMING (CT218) }

\end{center}
\vspace{0.2in}

\hspace{2.3in}Professor D.\ Bell

\hspace{2.3in}Dr.\ G.\ Lyons

\hspace{2.3in}Dr.\ M.\ Mc Gettrick

\hspace{2.3in}Mr.\ F.\ Smith

\vspace{0.1in}
\begin{center}
Time allowed: {\it three} hours.

Attempt {\it five} questions.

{\bf Please use a separate answer book for each section}
\end{center}


\vspace{0.3in}
\begin{center}
{\Large\bf Section A}
\end{center}

\begin{enumerate}

\item 
\begin{enumerate}

\item
Draw the binary tree that results from inserting
into an initially empty tree the following words in
the order given:
$$\hbox{\bf cracow, pisa, aachen, aalborg, metz, jaen}$$


\item
Calculate the depth of the tree in part (a). For the six 
words given, what is the (i) minimum,
(ii) maximum depth for all possible orderings?
Draw a sample tree which has minimum tree depth.

\item
For the initial tree in part (a), how many comparisons
need to be made using Binary Tree Search to find the word
{\bf jaen}?

\end{enumerate}

\vspace{0.3in}
\item
\begin{enumerate}
\item
Draw the graph corresponding to the adjacency matrix
\begin{displaymath}
\left( \begin{array}{ccc}
1 & 0 & 0\\
2 & 1 & 2\\
1 & 0 & 0\\
\end{array}\right)
\end{displaymath}

Use matrix multiplication to calculate how many distinct
ways there are of going from vertex (node) 1 to vertex 2
in three steps (i.e. paths of length 3)

\item
Describe the Selection Sort Algorithm. Use it to sort the 
five numbers {\bf 5, 9, 1, 7, 6} writing down the 
intermediate steps.

\end{enumerate}

\newpage
\item
\begin{enumerate}

\item
Explain the difference between procedures and functions in
Visual Basic.

\item
Out of the three families of operators in Visual Basic
(Arithmetic, Relational, Logical) which has (i) lowest,
(ii) highest precedence?

\item
Calculate the result of the following expressions:
\begin{enumerate}
\item
$4+2<6\ \hbox{\tt XOR TRUE}$
\item
$\hbox{\tt TRUE AND NOT}\ 5-1=2*2$
\item
$\hbox{\tt NOT FALSE AND}\ 5+4/2>6$
\end{enumerate}

\end{enumerate}

\vspace{0.3in}
\item
\begin{enumerate}

\item
Give examples of Visual Basic code to illustrate the difference
between a {\tt MessageBox} and an {\tt InputBox}. Illustrate also
the difference between a {\tt MessageBox} used in procedure and 
in function format.

\item
Describe, with examples, two methods and two properties of the 
{\tt ListBox} control.

\end{enumerate}


\vspace{0.3in}
\begin{center}
{\Large\bf Section B}
\end{center}

\item
\begin{enumerate}
\item Visual Basic supports two main file types. Describe
the use and benefits of both file types, giving
examples of relevant applications.
\item For each file type give examples of the code
for opening, closing and accessing files.
\end{enumerate}

\vspace{0.3in}
\item
\begin{enumerate}
\item Describe selection statements, 
giving examples and highlighting the role
of relational and logical operators.
\item Explain the difference between the different
repetition loops. 
Give an example of each.
\end{enumerate}

\vspace{0.3in}
\item
\begin{enumerate}
\item Write Visual Basic code to moves an object 
to the current position of the graphics cursor.
\item Write Visual Basic code that will draw a sequence
of 10 rectangles, each of the rectangles being half
as tall and wide as the previous one.
\item Present a Visual Basic program that will 
change the colour of the background in a form
to a random value every 10 seconds.

\end{enumerate}

\vspace{0.3in}
\item
\begin{enumerate}
\item Explain the differences between procedural
languages (such as C and Pascal) and event-driven languages
(such as Visual Basic). Use examples
as necessary.
\item Describe the necessary steps to create
a program in an event-driven language.
\item Explain the difference between modal and
modeless Dialog Boxes in Visual Basic.
\end{enumerate}


\end{enumerate}



\end{document}
