From 8673634024eb888ca4c78f34843417b2b08582cf Mon Sep 17 00:00:00 2001 From: Mark Date: Thu, 23 Mar 2023 10:23:44 -0700 Subject: [PATCH] Added AST warm-up --- Misc/Warm-Ups/ast.tex | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 Misc/Warm-Ups/ast.tex diff --git a/Misc/Warm-Ups/ast.tex b/Misc/Warm-Ups/ast.tex new file mode 100755 index 0000000..039b891 --- /dev/null +++ b/Misc/Warm-Ups/ast.tex @@ -0,0 +1,38 @@ +\documentclass[ + solutions, + nowarning, + singlenumbering, + nopagenumber +]{../../resources/ormc_handout} + +\usepackage[linguistics]{forest} + +\begin{document} + + \maketitle + {Warm-Up: What's an AST?} + {Prepared by Mark on \today. \\ Based on a true story.} + + + Say you have a valid string of simple arithmetic that contains no unary operators (like $3!$ or $-4$) and no parenthesis: + $$ + 3 + 9 \times 8 \div 5 \land 6 + $$ + + You may assume that all numbers and operators in this string consist of exactly one character. \\ + + Devise an algorithm that turns this string into a tree (as shown below), respecting the order of operations $[\land, \times, \div, +, -]$. + + \begin{center} + \begin{forest} + [$+$ + [3] + [$\div$ + [$\times$[9][8]] + [$\land$[5][6]] + ] + ] + \end{forest} + \end{center} + +\end{document} \ No newline at end of file