CSC 112
Lecture 11
Announcement: Presentation of the Computer Science Major,
Wednesday March 24, 12:151, MCConnell foyer. Please plan to attend.
Applications of Stacks
 Discussion of the homework: matching parentheses. How to
design the program, implement and test it.
 Evaluating arithmetic expressions. A special notation easily
understood by computers: Reverse Polish Notation. Prefix,
infix and postfix form.
 Fully parenthesized arithmetic expressions.
 Binary expression trees.

Polish notation.
Prefix, infix and postfix form (without parentheses).
 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.
Next two classes
 Design of an Arithmetic Expression class, with a function for
evaluating its postfix form.
 More applications of stacks: memory allocation for function calls.
 Queues.
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