iyidgnaw
5/12/2018 - 1:46 AM

stack.md

Stack

  • LIFO(Last In First Out)

  • if you use a linked list to achieve a stack, then your head pointer should always point at the top of the stack.

  • With array, you can have a limited capacity stack while with linkedlist you can have a unlimited one.

  • Useful method in the java.util.Stack class:

    empty();
    pop();
    push(e);
    peek(); //return the peek element without pop it.
    
  • With Stack, you can:

    • Reverse an array
    • check the pairwise status of a string.