\documentclass[11pt]{article}

\usepackage{exscale}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{latexsym}
\usepackage{times,mathptm}
\usepackage{epsfig}
\usepackage{amsmath}
\usepackage{enumitem}
\usepackage{mathpazo}
\usepackage{amssymb}
\usepackage{mathtools}
\usepackage{wrapfig}
\usepackage{tablists}

\graphicspath{ {.} }

\textwidth 6.5truein          
\textheight 9.5truein
\oddsidemargin 0.0in
\topmargin -0.5in
\thispagestyle{empty} 

\parindent 0pt          
\parskip 0pt

\begin{document}

\begin{large}
\centerline {\bf Computer Science 243}
\centerline {\bf Spring 2025}
\centerline {\bf Homework 12}
% \centerline{\bf My name}
\vskip .7cm

\bf Due: 11:59 p.m., Monday, 4/28/25 \hfill Points: 50
\end{large}
\vskip 0.5cm
Answer the following questions and show your work.  Your final submission must be completely your own work.

\begin{enumerate}

\vskip 0.5cm
\item {[4 points]}  For the graphs below, find the degree or in-degree/out-degree of each vertex.

\begin{enumerate}[label=\alph*.]
\itemsep-0mm

\item
\begin{minipage}[h]{.5\textwidth}
\includegraphics[width=.7\linewidth]{hw12pgraph1.png}
\end{minipage}%
b. \begin{minipage}[h]{.5\textwidth}
\includegraphics[width=.4\linewidth]{hw12pgraph2.png}
\end{minipage} \\
\end{enumerate}

%\begin{tabular}{lccc}
%\begin{minipage}[h]{\linewidth}
%\begin{enumerate}[label=\alph*.]
%\item
% a. & & b. & \\
% & \includegraphics[width=.35\linewidth]{hw12pgraph1.png} & &
% \includegraphics[width=.2\linewidth]{hw12pgraph2.png}
%\item
%kjk
%\end{enumerate}
%\end{minipage}%
%\end{tabular}


\vskip 0.5cm
\item {[4 points]}  State whether each graph is bipartite.  If so, list the elements in each vertex set.
\begin{enumerate}[label=\alph*.]
\itemsep-0mm
\item 
\begin{minipage}[h]{.5\textwidth}
\includegraphics[width=.8\linewidth]{hw12bipartite1.png}
\end{minipage}%
b. \begin{minipage}[h]{.6\textwidth}
\includegraphics[width=.4\linewidth]{hw12bipartite2.png}
\end{minipage} \\
\end{enumerate}


%\vskip 0.5cm
%\item {[3 point]} How many subgraphs of $W_3$ are possible with at least one vertex?


\vskip 0.5cm
\item {[2 points]} Represent the following graph with 
\begin{enumerate}[label=\alph*.]
\item an adjacency list (in alphabetical order of the vertices and the list for each vertex)
\item an adjacency matrix
\end{enumerate}

\makebox[1.5\linewidth][c]{%
\begin{minipage}[h]{\linewidth}{\centering}
\includegraphics[width=.4\linewidth]{hw12adjlist.png}
\end{minipage}}


\newpage

%\vskip 0.5cm
%\item {[2 points]} Draw a directed graph for the given adjacency matrix using labels $a, b, c, d$. \\
%
%\makebox[\linewidth][c]{%
%$\begin{bmatrix*}[r]
%1 & 1 & 1 & 0 \\
%0 & 0 & 1 & 0\\
%1 & 0 & 1 & 0 \\
%1 & 1 & 1 & 0 \\
%\end{bmatrix*}$ \\ }


\vskip 0.5cm
\item {[3 points]}  Determine whether the following two graphs are isomorphic.  If so, 
provide a mapping from one vertex set to the other.  If not, state why not.

\makebox[1.3\linewidth][c]{%
\begin{minipage}[h]{\linewidth}
\includegraphics[width=.6\linewidth]{hw12iso.png}
\end{minipage}}


\vskip 0.5cm
\item {[2 points]}  Determine whether each of the following graphs is strongly connected, and if not, whether it is weakly connected.
\begin{enumerate}[label=\alph*.]
\itemsep-0mm
\item 
\begin{minipage}[h]{.5\textwidth}
\includegraphics[width=.7\linewidth]{hw12conn1.png}
\end{minipage}%
b. \begin{minipage}[h]{.6\textwidth}
\includegraphics[width=.3\linewidth]{hw12conn2.png}
\end{minipage} 
\end{enumerate}


\vskip 0.5cm
\item {[2 points]}  Find the strongly connected components in the graph below.

\makebox[1.3\linewidth][c]{%
\begin{minipage}[h]{\linewidth}
\includegraphics[width=.6\linewidth]{hw12conncomp.png}
\end{minipage}}


\vskip 0.5cm
\item {[4 points]}  For each graph below, construct an Euler circuit if it exists.  If not, construct an Euler path if it exists.
\begin{enumerate}[label=\alph*.]
\itemsep-0mm
\item 
\begin{minipage}[h]{.4\textwidth}
\includegraphics[width=.7\linewidth]{hw12euler1.png}
\end{minipage}%
b. \begin{minipage}[h]{.4\textwidth}
\includegraphics[width=1.1\linewidth]{hw12euler2.png}
\end{minipage} \\
\end{enumerate}

\newpage

\vskip 0.5cm
\item {[3 points]}  Transform the following diagram into a graph and determine if someone can cross all of the bridges 
shown in this map exactly once and return to the starting point.  Label your graph and show a path, if possible, or explain 
why it cannot be done.

\makebox[1.3\linewidth][c]{%
\begin{minipage}[h]{\linewidth}
\includegraphics[width=.6\linewidth]{hw12bridges.png}
\end{minipage}}


\vskip 0.5cm
\item {[2 points]}  Determine whether the graph below has a Hamilton circuit.  If it does, find such a circuit.  If it does not, 
determine if it has a Hamilton path and find such a path.

\makebox[1.3\linewidth][c]{%
\begin{minipage}[h]{\linewidth}
\includegraphics[width=.3\linewidth]{hw12hamilton.png}
\end{minipage}}


\vskip .5cm
\item {[8 points]}  Answer the following questions for the tree shown below:\\

\makebox[1.3\linewidth][c]{%
\begin{minipage}[h]{\linewidth}
\includegraphics[width=.5\linewidth]{hw12tree.png}
\end{minipage}}

\begin{enumerate}[label=\alph*.]

\itemsep-0mm

\item Which vertex is the root?
\item Which vertices are internal?
\item Which vertices are leaves?
\item Which vertices are children of $b$?
\item Which vertex is the parent of $h$?
\item Which vertices are siblings of $o$?
\item Which vertices are ancestors of $m$?
\item Which vertices are descendants of $b$?
\end{enumerate}

\newpage


\vskip .5cm
\item {[6 points]}  For the tree in the previous problem, list the vertices in the order that they would be visited in a(n):

\begin{enumerate}[label=\alph*.]

\itemsep-0mm

\item preorder traversal
\item inorder traversal
\item postorder traversal
\end{enumerate}


\vskip .5cm
\item {[6 points]}  Consider the following infix expression: \\

\centerline{$((x+2)$\textasciicircum$3)*(y-(3+x))-5$}

\begin{enumerate}[label=\alph*.]

\itemsep-0mm

\item Draw a binary expression tree for the expression.
\item Write this expression in prefix notation.
\item Write this expression in postfix notation.
\end{enumerate}


\vskip .5cm
\item {[2 points]}  Compute the value of each of the following: 
\begin{enumerate}[label=\alph*.]
\itemsep-0mm

\item the prefix expression: $+ - + 4 * 2\  3\  8\  5$
\item the postfix expression: $5\  2\  1 - - 3\  1\  4\  + + *$
\end{enumerate}


\vskip 0.5cm
\item {[2 points]}  Find a spanning tree for the graph below by removing edges in simple circuits:

\makebox[1.3\linewidth][c]{%
\begin{minipage}[h]{\linewidth}
\includegraphics[width=.5\linewidth]{hw12spanningtree.png}
\end{minipage}}


\end{enumerate}

\end{document}
