# CS 112

Lecture 10

Stacks

Applications of Stacks

## Stacks

- The
Stack abstract data type.
- The Java Stack, and why what we implement is not identical to this version.

## Applications of Stacks

- Evaluating arithmetic expressions. A special notation easily
understood by computers:
**Reverse Polish Notation**.
- 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.

**Warning:**
The topics covered in these lectures 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.

### Lab

Start working on the homework. Implementing a Stack class and a testdriver. Along the way, learn the following:
- Here is an example of an application using
console input and output.
- Some notes on Java file I/O.
- Look into the Integer
class for ParseInt conversion method (from String to Integer).
- Reading and writing to files (Java application).
**Exceptions**
- Error handling. Exceptions.
**catch** and **throw**
- Read from Hasti -> Lesson 3 -> Exceptions.
- We'll get back to this topic in more detail later.

Ileana Streinu