• Breaking News

    Funny Coder

    Funny coder is an open source web for interested programmer. It is a programming environment.It's a way where you can code with fun.

    Monday, April 11, 2016

    Stack definition and it's kinds


    Definition of stack:

    Stack is a special type of data structure where elements are inserted from one end and elements are deleted from the same end. The position from where elements a are inserted and from where elements are deleted
    is termed as top of the stack. Thus stack is a homogeneous collection of elements of any one type, arranged linearly with access at one end only.
    Stack is also called the LIFO. That means Last On First Out. Which elements enter to the stack at last, will out first from the stack.

    stack_example || funny Coder


    Stack has basically two methods, methods are-

    1. Push: Inserting an item to the stack
    2. Pop: Deleting an item from the stack

    Stack push() method:
     





    Before push the value stack top was = 5 || After push 20 the stack, now top is 20



    1. Push Option for stack:

    1. void push(K o)
    2. Pushes the given object on the stack.
    3. Parameters:
    4. o - the object that will become the new top of the stack.

    2.Pop Option in stack:

    1. K pop()
    2. Pops the top off the stack.
    3. Returns:
    4. the top of the stack.









    No comments:

    Post a Comment

    Fashion

    Beauty

    Travel