CSC 112
Lecture 12
Applications of Stacks
- Evaluating arithmetic expressions. A special notation easily
understood by computers: Reverse Polish Notation. Prefix,
infix and postfix form.
- Fully parenthesized arithmetic expressions.
- Later we'll also do: Binary expression trees.
-
Polish notation.
Prefix, infix and postfix form.
- Evaluating arithmetic expressions in postfix form using a
stack.
- Work out a few examples.
- Implementing this algorithm (evaluation of arithmetic
expressions in postfix form) in C++ will be the topic of the next
homework 6.
- We'll get back to this topic later in a few weeks, and you
will implement the algorithm to convert an arithmetic expression
to postfix form (and more).
- We'll see more about trees in a few weeks - and you will
implement this data structure.
Next time, before the exam
- More applications of stacks: memory allocation for function calls.
- Midterm review; what we did so far, what will be on the exam.
Warning:
The topics covered in these two classes are VERY important. Without a clear
understanding of these applications of stacks, you might have
serious difficulty in this class from now on. Please stop me,
ask frequent questions, work out examples on your own after
class, come to my office hours and make sure everything is absolutely
clear before the exam. The next homework will be a
relatively challenging one and requires thorough understanding of
these concepts.
Ileana Streinu