4. Stacks and Queues

In this chapter we’ll examine three data storage structures: the stack, the queue, and the priority queue. We’ll begin by discussing how these structures differ from arrays; then we’ll examine each one in turn. In the last section, we’ll look at an operation in which the stack plays a significant role: parsing arithmetic expressions.

A Different Kind of Structure

There are significant differences between the data structures and algorithms we’ve seen in previous chapters and those we’ll look at now. We’ll discuss three of these differences before we examine the new structures in detail.

Programmer’s Tools ...

Get Data Structures and Algorithms in Java, 2nd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.