About Me

Thursday, February 5, 2009

Data Structure - Stack

Stack


"The stack is a very common data structure used in programs. By data structure, we mean something that is meant to hold data and provides certain operations on that data[Wiki]".

fig.1 Illustration of Stack

A "STACK OF BOOKS" is a good example to understand the concept of it.

♥we have a stack of books
♥we place a book on the top - PUSH
♥we take one off in the top - POP

More complex operations to be inappropriate for our stack. For example, pulling out the 3rd book from the top cannot be done directly because the stack might fall over. According to our instructor it is "CHEATING".


Methods/Operations:

☻isEmpty()

☻Push()

☻Pop()

☻Top()

☻display()

☻size()

Reference:

[Wiki]

http://www.nationmaster.com/encyclopedia/Stack-data-structure

No comments:

Post a Comment