\documentstyle{article}

\newcommand{\set}[2]{\bigl\{\, #1 \,\big|\, #2 \,\bigr\}}
\begin{document}

{\large \bf Lecture 8}\hfill 21 September 1993

\begin{enumerate}
                          
\item Went over solution set 3.

\item Stacks: example from Sedgewick's book on
  arithmetic evaluation. Using linked list
  as stack.

\item {\bf Trees.}

\item
  Terminology: vertices or nodes, edges are pairs of
    nodes. 
\item
  Path: sequence of distinct nodes such that successive
    nodes in list are edges. Also, single node is a path.
\item
  Root: a distinguished node.
\item
  Tree: for every vertex there is a unique path from the
    root to the vertex.
\item
  Direction: from root to vertex. Parent and children.
\item
  Subtree: vertex (as new root) and all its descendants.
\item
  Ordered tree, forest, full etc.
\item
  Properties: 1-5 from Sedgewick. However, the first was more
    difficult to establihs than I thought. Here is how.

\begin{quote}
  {\em Theorem:} In a tree there is a unique path between any two
    nodes:

  {\em Proof:} 
  Existence. Let $r$ be the root, and $v_1, v_2$ the vertices.
    If either or both $v_i=r$ done.

    So let $p_i$ be paths from $v_i$ to $r$ and choose $\pi$ to be the vertex
    which is the last time the $p_i$ intersect as one travels
    from $r$ to $v_2$. Then $v_1 - \pi - v_2$ is a path.

    Uniqueness: 
    Suppose $\pi_i$ for  $i=1,2$ are two distinct paths from $v$ to $w$.
    Follow both paths from $v$ until it splits. Replace $v$ with the
    node at which it splits. Hence $(v,v_i)$ begins $\pi_i$ and
    $v_1\neq v_2$. Let $w^*$ be the first time $\pi_2$ hits $\pi_1$
    (as one moves from $v$ to $w$). Replace $w$ by $w^*$. Hence
    $\pi_i$ are a simple cycle (at least three edges) joining $w$ and $v$.

    If the root is on the cycle, then there are two paths from the
    root to any other node on the cycle by traversing the cycle clockwise or
    counter-clockwise..

    If the root is not on the cycle, choose any node of the cycle and
    connect it to the root. Then working back, let $r^*$ be the first
    node on the path from the root to the cycle which hits the cycle.
    Replace the route with $r$ to $r^*$. There are two distinct paths
    from the root to anything on the cycle, consisting of the path
    from $r$ to $r^*$ then traversing the cycle clockwise or counter-clockwise.

    

\end{quote}
\end{enumerate}

\end{document}

  
