\documentstyle[oneside,hmwk,11pt,psfig]{handout}
\hmwknumber{3}
\topic{Priority Queues, Search Trees}
\duedate{Tuesday, 16 July 1996}
\begin{document}
\maketitle

\vspace{-0.4in}

\section*{Reading}
\vspace{-0.1in}
Read Ch. 7, 13.1--13.3, and pp.197--198 of CLR.


\section*{Practice}
\vspace{-0.1in}
Recall, these exercises are purely for your own practice.  You need
only turn in the official problems.
\begin{itemize}
\item Do CLR 7.5-6.

\item Do CLR 13.1-2, 13.2-1, 13.2-6, 13.3-3.

\end{itemize}


\section*{Problems}
\vspace{-0.1in}

Consider maintaining a collection of people in a binary tree.  For
each person, we have both a name and an age.  We will call this
structure 
structure a {\em treap} (tree + heap) if it is a binary search tree
with respect to the names and, simultaneously, a heap with
respect to the ages.  
For example, for the set,
$$ \{
(Alice,13),(Bob,26),(Cathy,19),(David,30),(Eve,27),(Fred,22)
\}$$ 
the tree shown below satisfies the conditions.

\hspace{0.5in}

\centerline{\psfig{figure=hw03-fig.eps}}

\begin{enumerate}
\item You must prove the following claim.  Let $S$ be a set of people
such that the names and ages are distinct.  There always exists such a
tree which satisfies the above properties, and in fact, such a tree is
unique for a given set.

\item Do CLR 10-1.

\item Do CLR 13.3-4.

\item Give a nonrecursive algorithm that performs a postorder tree
walk. (Hint:  There is an easier solution that uses a stack as an
auxiliary data structure, and a more complicated but elegant solution
that uses only constant amount of auxiliary storage, but assumes that
two pointers can be tested for equality.)

\end{enumerate}


\section*{Extra Credit}
\vspace{-0.1in}

For extra credit, give the ``elegant'' solution to problem~4 above
which uses only a constant amount of additional storage.

{\em Do not jeopardize your solution to problem~4 by attempting this
extra credit.}  That is, you may certainly write up problem~4 with the
easier solution to get credit for the main part of the homework, and
then you may write up a second solution, here, for the extra credit
attempt.

If you feel your original solution to problem~4, satisfies the extra
credit, than you may simply write a note which refers us to your
original solution, but if that solution is incorrect, not only will
you not receive extra credit, but you will have also lost points on
the actual homework.

\end{document}

