Homework 13

.tex

School

Texas A&M University *

*We aren’t endorsed by this school

Course

222

Subject

Computer Science

Date

Feb 20, 2024

Type

tex

Pages

7

Uploaded by PrivateSteelKomodoDragon37

Report
% Comment lines start with % % LaTeX commands start with \ % This template was provided by Jennifer Welch for CSCE 222-200, Honors, Spring 2015 \documentclass[12pt]{article} % This is an article with font size 12-point % Packages add features \usepackage{times} % font choice \usepackage{amsmath} % American Mathematical Association math formatting \usepackage{amsthm} % nice formatting of theorems \usepackage{amssymb} % provides some symbols \usepackage{latexsym} % provides some more symbols \usepackage{fullpage} % uses most of the page (1-inch margins) \usepackage[shortlabels]{enumitem} \usepackage{graphicx} \usepackage{tikz} \setlength{\parskip}{.1in} % increase the space between paragraphs \renewcommand{\baselinestretch}{1.1} % increase the space between lines % Convenient renaming of symbols for logic formulas \newcommand{\NOT}{\neg} \newcommand{\AND}{\wedge} \newcommand{\OR}{\vee} \newcommand{\XOR}{\oplus} \newcommand{\IMPLIES}{\rightarrow} \newcommand{\IFF}{\leftrightarrow} \providecommand{\myceil}[1]{$\left \lceil #1 \right \rceil$} \providecommand{\myfloor}[1]{$\left \lfloor #1 \right \rfloor$} \newcommand{\powerset}[1]{\mathbb{P}(#1)} % Actual content starts here. \begin{document} \begin{center} % center all the material between begin and end {\large % use larger font CSCE 222 (Carlisle), Discrete Structures for Computing \\ % \\ is line break Spring 2022 \\ Homework 13} \end{center} \rule{6in}{.1pt} % horizontal line 6 inches long and .1 point high \begin{center} {\large Type your name below the pledge to sign\\ On my honor, as an Aggie, I have neither given nor received unauthorized aid on this academic work.\\ Huy QUANG LAI} \end{center} % blank line separates paragraphs. First line of a paragraph is automatically % indented. \rule{6in}{.1pt} % horizontal line 6 inches long and .1 point high \noindent % don't indent {\bf Instructions:} % \bf makes text boldface % \em makes text emphasized (italics)
\begin{itemize} % makes an itemized list \item The exercises are from the textbook. You are encouraged to work extra problems to aid in your learning; remember, the solutions to the odd-numbered problems are in the back of the book. \item Grading will be based on correctness, clarity, and whether your solution is of the appropriate length. \item Always justify your answers. \item Don't forget to acknowledge all sources of assistance in the section below, and write up your solutions on your own. \item {\em Turn in .pdf file to Gradescope by the start of class on Monday, May 2, 2022.} It is simpler to put each problem on its own page using the LaTeX clearpage command. \end{itemize} \rule{6in}{.1pt} % horizontal line 6 inches long and .1 point high {\bf Help Received:} % \bf makes text boldface \begin{itemize} \item Rosen, Kenneth H. \textit{Discrete Mathematics and Its Applications}. McGraw- Hill, 2019. \item Wallace, Evan. \textit{Finite State Machine Designer}, 2010, madebyevan.com/fsm/. \end{itemize} \rule{6in}{.1pt} % horizontal line 6 inches long and .1 point high %--------------------------------------------------------------------- % \subsection makes a subsection heading; * leaves it unnumbered. % (Usually subsections are inside sections, but the \section command % used a font that was larger than I wanted.) \subsection*{Exercises for Section 13.1:} \noindent {\bf 4(a-c): (3 points).} \noindent Let $G=(V,T,S,P)$ be the phrase-structure grammar with $V=\{0, 1, A, S\},T=\{0, 1\}$, and set of productions $P$ consisting of $S\to1S,S\to00A,A\to0A$, and $A\ to0.$ \begin{enumerate}[a)] \item Show that 111000 belongs to the language generated by $G$.\\ $S\Rightarrow1S\Rightarrow11S\Rightarrow111S\Rightarrow11100A\Rightarrow111000$ \item Show that 11001 does not belong to the language generated by $G$.\\ Every production results in a string ending in $S,A$ or $0$. Therefore, any string ending with $1$ is not possible. \item What is the language generated by $G$?\\ The string can start any number of 1’s, including zero, by iterating the production $S\to1S$.\\ Eventually the $S$ must turn into $00A$, so at least two 0’s must come next.\\ The string can then contain additional 0's using $A\to0A$ repeatedly.\\ Because $A\to0$ is called at the end, this adds at least one more 0 (and therefore a total of at least three 0’s).\\ So the language generated by $G$ is the set of all strings consisting of zero or more 1’s followed by three or more 0’s. We can write this as $\{0^n1^m\vert n\
geq0$ and $m\geq3 \}$. \end{enumerate} \noindent {\bf 18(a,c): (2 points).} \noindent Construct phrase-structure grammars to generate each of these sets. \begin{enumerate}[a)] \item $\{01^{2n}\vert n\geq0\}$\\ Exactly one 0. Followed by an even number of 1.\\ $S\to0A$\\ $A\to11A$\\ $A\to\lambda$ \setcounter{enumi}{2} \item $\{0^n1^m0^n\vert m\geq0\textrm{ and }n\geq0\}$\\ Grow 0's from the center. Convert the center into a 1-making machine.\\ $S\to0S0$\\ $S\to A$\\ $A\to1A$\\ $A\to\lambda$ \end{enumerate} \clearpage \noindent {\bf 24b: (1 point).} \noindent Let $G$ be the grammar with $V=\{a,b,c,S\};T=\{a, b, c\}$; starting symbol $S$; and productions $S\to abS, S\to bcS,S\to bbS,S\to a,$ and $S\to cb$. Construct derivation trees for $bbbcbba$. \begin{enumerate} \item $S\to bbS$ \item $S\to bcS$ \item $S\to bbS$ \item $S\to a$ \end{enumerate} \clearpage \subsection*{Exercises for Section 13.2:} \noindent {\bf 4(a-c): (3 points).} \noindent Find the output generated from the input string $10001$ for the finite-state machine with the state diagram in \begin{enumerate}[a)] \item Exercise 2(a).\\ The machine starts in state $s_0$.\\ On input $1$, it moves to state $s_2$ and outputs $0$.\\ The next three inputs of 0's drive it to state $s_3$, then to $s_1$, then back to $s_0$. This will output $011$.\\ The final $1$ drives it back to $s_2$ and outputs $0$.\\ The output is $00110$. \item Exercise 2(b).\\ The machine starts in state $s_0$.\\
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help