The stack abstract data type

This post is the second post of the data structures.This post will be cover the main topic in data structures.
  •  The stack abstract data type.

First let's discuss about the first topic.

The stack abstract data type

The stack abstract data type is defined by the following structure and operations.
The stack ordered "Last in first out" mechanism.

The stack operations are given below.

stack( )
  • creates a new stack that is empty. It needs no parameters and returns an empty stack.

push( item )
  • adds a new item to the top of the stack. It needs the item and returns nothing.

pop( )
  • removes the top item from the stack. It needs no parameters and returns the item.The stack  is not modified.
peek( )
  • returns the top item from the stack but does not remove it. It needs no parameters. The stack is not modified.

isEmpty( )
  • tests to see whether the stack is empty. It needs no parameters and returns a Boolean.

size( )
  • returns the number of items on the stack. It needs no parameters and returns an integer.
 Let's See a simple Example of these operations.


Now I think you can clearly identify the stack abstract type and it's operations.

My next post will be implementing the stack using python.

I think you get some knowledge about stack abstract data type.

See you soon.
Thank you

Comments

Popular posts from this blog

Algorithm I

love java programming

Loops