Skip to Main Content
Introducing Data Structures with Java
book

Introducing Data Structures with Java

by David Cousins
March 2013
Intermediate to advanced content levelIntermediate to advanced
416 pages
9h 41m
English
Pearson Education India
Content preview from Introducing Data Structures with Java

11

Stacks

Stacks

Contents

  • Stacks as data structures
  • Stacks: array versus dynamic implementations
  • Stack operations—push, pop, view
  • A stack class (two versions)
  • Stack applications
11.1 INTRODUCTION

A ‘stack’ is a structure based upon the linked list and is similar in some ways to a queue, but with a distinct difference. Whereas the latter is ‘FIFO’ (first in, first out), the former is ‘LIFO’ (last in, first out). A stack resembles a pile of plates (Figure 11.1)-new ones are placed on top of the stack, and an attempt to remove any but the top one is likely to end in disaster!

Figure 11.1 Operations on a stack

11.2 STACKS AND THEIR OPERATIONS ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Data Structures and Algorithms Using Java

Data Structures and Algorithms Using Java

William McAllister

Publisher Resources

ISBN: 9788131758649