Warm-ups
This commit is contained in:
43
src/Warm-Ups/What's an AST/main.tex
Executable file
43
src/Warm-Ups/What's an AST/main.tex
Executable file
@ -0,0 +1,43 @@
|
||||
\documentclass[
|
||||
solutions,
|
||||
hidewarning,
|
||||
singlenumbering,
|
||||
nopagenumber
|
||||
]{../../../lib/tex/ormc_handout}
|
||||
\usepackage{../../../lib/tex/macros}
|
||||
|
||||
|
||||
\usepackage[linguistics]{forest}
|
||||
|
||||
|
||||
|
||||
\title{Warm-Up: What's an AST?}
|
||||
\uptitler{\smallurl{}}
|
||||
\subtitle{Prepared by Mark on \today. \\ Based on a true story.}
|
||||
|
||||
\begin{document}
|
||||
|
||||
\maketitle
|
||||
|
||||
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}
|
6
src/Warm-Ups/What's an AST/meta.toml
Normal file
6
src/Warm-Ups/What's an AST/meta.toml
Normal file
@ -0,0 +1,6 @@
|
||||
[metadata]
|
||||
title = "What's an AST?"
|
||||
|
||||
[publish]
|
||||
handout = true
|
||||
solutions = false
|
Reference in New Issue
Block a user