Sunday, February 8, 2009

STACK

Definition:

  • is an abstract data type and data structure based on the principle of Last In First out (LIFO).
  • are used extensively at every level of a modern computer system.
  • s a container of nodes and has two basic operations: push and pop. Push adds a given node to the top of the stack leaving previous nodes below. Pop removes and returns the current top node of the stack.  [1.] [en.wikipedia.org/wiki/Stack_(data_structure)]

      The key methods of the Stack class are push(), peek(), pop(), empty() and search():
            push() - adds an element to the top of the stack.
            peek() - returns the first element from the top of the stack without removing it from the                                stack.
            pop() - as peek() but removes it from the stack.
            empty() - checks wheter there are elements in the stack or not

            search() - returns the position of an element in the stack. [2.] http://www.javadb.com/using-                                 a-stack

Illustration:



This figure is a representation of stack from [1.] http://en.wikipedia.org/wiki/Stack_(data_structure)


references:

[1.] http://en.wikipedia.org/wiki/Stack_(data_structure)
[2.] http://www.javadb.com/using-a-stack


No comments:

Post a Comment