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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.