hws/hw09.tex
changeset 459 780486571e38
parent 359 db106e5b7c4d
child 525 a2ee4b11c976
equal deleted inserted replaced
458:896a5f91838d 459:780486571e38
     1 \documentclass{article}
     1 \documentclass{article}
     2 \usepackage{../style}
     2 \usepackage{../style}
     3 \usepackage{../graphics}
     3 \usepackage{../graphics}
       
     4 \usepackage{../langs}
     4 
     5 
     5 \begin{document}
     6 \begin{document}
     6 
     7 
     7 \section*{Homework 9}
     8 \section*{Homework 9}
     8 
     9 
     9 \HEADER
    10 \HEADER
    10 
    11 
    11 \begin{enumerate}
    12 \begin{enumerate}
    12 \item Describe what is meant by \emph{eliminating tail
    13 \item Describe what is meant by \emph{eliminating tail
    13       recursion}, when such an optimization can be applied and
    14       recursion}? When can this optimization be applied and
    14       why it is a benefit?
    15       why is it of benefit?
       
    16 
       
    17 \item A programming language has arithmetic expression. For an
       
    18   arithmetic expression the compiler of this language produces the
       
    19   following snippet of JVM code.
       
    20 
       
    21 \begin{lstlisting}[language=JVMIS,numbers=none]
       
    22 ldc 1 
       
    23 ldc 2 
       
    24 ldc 3 
       
    25 imul 
       
    26 ldc 4 
       
    27 ldc 3 
       
    28 isub 
       
    29 iadd 
       
    30 iadd
       
    31 \end{lstlisting}
       
    32 
       
    33   Give the arithmetic expression that produced this code.  Make sure
       
    34   you give all necessary parentheses.
       
    35 
       
    36 \item Describe what the following two JVM instructions do!
       
    37 
       
    38 \begin{lstlisting}[language=JVMIS,numbers=none]
       
    39 iload 3
       
    40 istore 1
       
    41 \end{lstlisting}
       
    42 
       
    43 \item \POSTSCRIPT  
    15 
    44 
    16 %  \item It is true (I confirmed it) that
    45 %  \item It is true (I confirmed it) that
    17 %  
    46 %  
    18 %  \begin{center} if $\varnothing$ does not occur in $r$
    47 %  \begin{center} if $\varnothing$ does not occur in $r$
    19 %  \;\;then\;\;$L(r) \not= \{\}$ 
    48 %  \;\;then\;\;$L(r) \not= \{\}$