\documentstyle[12pt]{report}
\pagestyle{myheadings}
\def\headlineaux{\sc Math 220/317: Programming II/Data Structures 
\hrulefill
}
\markboth{\headlineaux}{\headlineaux}

\newcommand{\assignmentNumber}{4}
\newcommand{\outdate}{16 September, 1993}
\newcommand{\duedate}{24 September, 1993}

\begin{document}
\begin{titlepage}\begin{centerline}{\Huge \framebox{Burt Rosenberg}}
\end{centerline}\end{titlepage}

\section*{Problem Set \assignmentNumber \hfill{\parbox{3in}
    {\small\sc\begin{flushright} Out: \outdate
     \\ Due: \duedate\end{flushright}}}}

\subsection*{Goals}
Practice using pointers, linked lists and text files.

\subsection*{Reading Assignment}
Read Chapter 3 from {\em Algorithms} by Robert Sedgewick.

\subsection*{Programming Assignment}
Write a program which keeps a linked list of the
{\em unique} words in a text file, along with a
count as to how many times each unique word appeared
in the text. For instance, the text
``Romeo, Romeo! wherefore art thou Romeo?''
has 4 unique words, ``romeo'' with a count of 3,
``wherefore'', ``art'' and ``thou'' each with a
count of 1.

The output should be the total number of words, the
number of unique words,
and a list of the unique words with their count.
To make sure your code really works,
you should take a small file and watch what it
does with each word read. Below I give an example
session for a very small file.
Hand in a file which is a record of this session.

As a guide to the solution, I suggest you work as follows:
\begin{enumerate}
\item Change the type of the nodes in the list to also
  have a field {\em count} of type integer. 
\item Write a function to check equality of strings.
\item Write a function returning a pointer to a node in the
  list or {\em nil} which searches a list for a match with
  a given string.
\item Combine the above to implement the unique words program.
\end{enumerate}

\subsection*{Testing}

In the given example, here is the sequence of lists.
The variable $p$ is the list's anchor.
\begin{enumerate}
\item First, there is an empty list, assume a dummy header node
  carrying a nonsense string $\Omega$ with count $0$,
\[  p \longrightarrow ( \Omega, 0 ) \]
\item Next, the word ``romeo'' is inserted:
\[  p \longrightarrow ( \Omega, 0 ) \longrightarrow
      ( \mbox{romeo}, 1 ) \]
\item Again, ``romeo'':
\[  p \longrightarrow ( \Omega, 0 ) \longrightarrow
      ( \mbox{romeo}, 2 ) \]
\item Now, ``wherefore'' is added to the front:
\[  p \longrightarrow ( \Omega, 0 ) \longrightarrow
      ( \mbox{wherefore}, 1 ) \longrightarrow
      ( \mbox{romeo}, 2 ) \]
\item And ``art'' and ``thou'' (skipping ahead):
\[  p \longrightarrow ( \Omega, 0 ) \longrightarrow
      ( \mbox{thou}, 1 ) \longrightarrow
      ( \mbox{art}, 1 ) \longrightarrow
      ( \mbox{wherefore}, 1 ) \longrightarrow
      ( \mbox{romeo}, 2 ) \]
\item Finally, another ``romeo'':
\[  p \longrightarrow ( \Omega, 0 ) \longrightarrow
      ( \mbox{thou}, 1 ) \longrightarrow
      ( \mbox{art}, 1 ) \longrightarrow
      ( \mbox{wherefore}, 1 ) \longrightarrow
      ( \mbox{romeo}, 3 ) \]
\end{enumerate}
Have your code print out after every word, to make sure
this sequence is what you get.
The final output for this test is:
\begin{verbatim}
     6 words in the file,
     4 unique words. They are:
        thou       1
        art        1
        wherefore  1
        romeo      3
\end{verbatim}
\end{document}
