P. 1
thinkapjava

thinkapjava

|Views: 53|Likes:
Published by kantti

More info:

Published by: kantti on May 15, 2008
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

10/14/2011

pdf

text

original

In this chapter we will look at one common ADT, the stack. A stack is a

collection, meaning that it is a data structure that contains multiple elements.

Other collections we have seen include arrays and lists.

As I said, an ADT is defined by a set of operations. Stacks can perform the

following set of operations:

constructor: Create a new, empty stack.

push: Add a new item to the stack.

pop: Remove and return an item from the stack. The item that is returned is

always the last one that was added.

isEmpty: Check whether the stack is empty.

A stack is sometimes called a “last in, first out,” or LIFO data structure, because

the last item added is the first to be removed.

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->