23.11.2014 Views

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

206<br />

5.2.3<br />

Implement<strong>in</strong>g a Queue with a Generic L<strong>in</strong>ked List....<br />

210<br />

5.2.4<br />

Round Rob<strong>in</strong> Schedulers.............................<br />

211<br />

5.3<br />

Double-Ended Queues.................................<br />

213<br />

5.3.1<br />

The Deque Abstract <strong>Data</strong> Type.......................<br />

213<br />

5.3.2<br />

Implement<strong>in</strong>g a Deque...............................<br />

214<br />

5.4<br />

Exercises...........................................<br />

217<br />

java.datastructures.net<br />

5.1 Stacks<br />

A stack is a collection of objects that are <strong>in</strong>serted <strong>and</strong> removed accord<strong>in</strong>g to the last<strong>in</strong><br />

first-out (LIFO) pr<strong>in</strong>ciple. Objects can be <strong>in</strong>serted <strong>in</strong>to a stack at any time, but<br />

only the most recently <strong>in</strong>serted (that is, "last") object can be removed at any time. The<br />

name "stack" is derived from the metaphor of a stack of plates <strong>in</strong> a spr<strong>in</strong>g-loaded,<br />

cafeteria plate dispenser. In this case, the fundamental operations <strong>in</strong>volve the<br />

"push<strong>in</strong>g" <strong>and</strong> "popp<strong>in</strong>g" of plates on the stack. When we need a new plate from the<br />

dispenser, we "pop" the top plate off the stack, <strong>and</strong> when we add a plate, we "push" it<br />

260

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!