cws/core_cw03.tex
changeset 498 0f1b97538ad4
parent 472 fbff6f601370
child 501 3717785f2c37
equal deleted inserted replaced
497:ef37fb04a343 498:0f1b97538ad4
    14 \begin{document}
    14 \begin{document}
    15 
    15 
    16 % BF IDE
    16 % BF IDE
    17 % https://www.microsoft.com/en-us/p/brainf-ck/9nblgggzhvq5
    17 % https://www.microsoft.com/en-us/p/brainf-ck/9nblgggzhvq5
    18   
    18   
    19 \section*{Core Part 3 (Scala, 3 Marks)}
    19 \section*{Core Part 3 (Scala, 2 Marks)}
    20 
    20 
    21 \mbox{}\hfill\textit{``[Google’s MapReduce] abstraction is inspired by the}\\
    21 \mbox{}\hfill\textit{``[Google’s MapReduce] abstraction is inspired by the}\\
    22 \mbox{}\hfill\textit{map and reduce primitives present in Lisp and many}\\
    22 \mbox{}\hfill\textit{map and reduce primitives present in Lisp and many}\\
    23 \mbox{}\hfill\textit{other functional languages.''}\smallskip\\
    23 \mbox{}\hfill\textit{other functional languages.''}\smallskip\\
    24 \mbox{}\hfill\textit{ --- Dean and Ghemawat, who designed this concept at Google}
    24 \mbox{}\hfill\textit{ --- Dean and Ghemawat, who designed this concept at Google}
    60 One way to calculate the the power operation is to use \texttt{.pow}
    60 One way to calculate the the power operation is to use \texttt{.pow}
    61 on \texttt{BigInt}s, like \texttt{BigInt(n).pow(m).toInt}.
    61 on \texttt{BigInt}s, like \texttt{BigInt(n).pow(m).toInt}.
    62 \bigskip
    62 \bigskip
    63 
    63 
    64 
    64 
    65 \subsection*{Core Part (3 Marks, files postfix.scala, postfix2.scala)}
    65 \subsection*{Core Part (2 Marks, files postfix.scala, postfix2.scala)}
    66 
    66 
    67 The \textit{Shunting Yard Algorithm} has been developed by Edsger Dijkstra,
    67 The \textit{Shunting Yard Algorithm} has been developed by Edsger Dijkstra,
    68 an influential computer scientist who developed many well-known
    68 an influential computer scientist who developed many well-known
    69 algorithms. This algorithm transforms the usual infix notation of
    69 algorithms. This algorithm transforms the usual infix notation of
    70 arithmetic expressions into the postfix notation, sometimes also
    70 arithmetic expressions into the postfix notation, sometimes also
   157 
   157 
   158 \item[(2)] Implement a compute function that takes a postfix expression
   158 \item[(2)] Implement a compute function that takes a postfix expression
   159   as argument and evaluates it generating an integer as result. It uses a
   159   as argument and evaluates it generating an integer as result. It uses a
   160   stack to evaluate the postfix expression. The operators $+$, $-$, $*$
   160   stack to evaluate the postfix expression. The operators $+$, $-$, $*$
   161   are as usual; $/$ is division on integers, for example $7 / 3 = 2$.
   161   are as usual; $/$ is division on integers, for example $7 / 3 = 2$.
   162   \hfill[1 Mark]
   162   \hfill[0.5 Marks]
   163 \end{itemize}
   163 \end{itemize}
   164 
   164 
   165 \subsubsection*{Task (file postfix2.scala)}
   165 \subsubsection*{Task (file postfix2.scala)}
   166 
   166 
   167 \begin{itemize}
   167 \begin{itemize}
   169   operator.  This requires proper account of associativity of
   169   operator.  This requires proper account of associativity of
   170   the operators. The power operator is right-associative, whereas the
   170   the operators. The power operator is right-associative, whereas the
   171   other operators are left-associative.  Left-associative operators
   171   other operators are left-associative.  Left-associative operators
   172   are popped off if the precedence is bigger or equal, while
   172   are popped off if the precedence is bigger or equal, while
   173   right-associative operators are only popped off if the precedence is
   173   right-associative operators are only popped off if the precedence is
   174   bigger.\hfill[1 Marks]
   174   bigger.\hfill[0.5 Marks]
   175 \end{itemize}
   175 \end{itemize}
   176 
   176 
   177 \end{document}
   177 \end{document}
   178 
   178 
   179 
   179