Introduction
An array is a random access data structure, where each element can be accessed directly and in constant time. A typical illustration of random access is a book – each page of the book can be open independently of others. Random access is critical to many algorithms, for example, binary search.
A linked list is a sequential access Data Structure, where each element can be accessed only in a particular order. A typical illustration of sequential access is a roll of paper or tape – all prior material must be enrolled in order to get to data you want. In this note, we consider a subcase of sequential data structures, socalled limited access data structures.
Also See, Array Implementation of Queue and Rabin Karp Algorithm
Stacks
A stack is a container of objects that are inserted and removed according to the lastinfirstout (LIFO) principle. In the pushdown stacks only two operations are allowed: push the item into the stack, and pop the item out of the stack. A stack is a limited access data structure – elements can be added and removed from the stack only at the top. push adds an item to the top of the stack, pop removes the item from the top. A helpful analogy is to think of a stack of books; you can remove only the top book, also you can add a new book on the top.
A stack is a recursive data structure. Here is a structural definition of a Stack: A stack is either empty or it consists of a top and the rest which is a stack.
Applications

The simplest application of a stack is to reverse a word. You push a given word to stack – letter by letter – and then pop letters from the stack
 Another application is an “undo” mechanism in text editors; this operation is accomplished by keeping all text changes in a stack
Backtracking
This is a process when you need to access the most recent data element in a series of elements. Think of a labyrinth or maze – how do you find a way from an entrance to an exit? Once you reach a dead end, you must backtrack. But backtrack to where? to the previous choice point. Therefore, at each choice point, you store on a stack all possible choices. Then backtracking simply means popping a next choice from the stack.
Language Processing

Space for parameters and local variables is created internally using a stack

Compiler’s syntax check for matching braces is implemented by using stack
 Support for recursion
Arithmetic Expression Evaluation
An important application of stacks is in parsing. For example, a compiler must parse arithmetic expressions written using infix notation:
1 + ((2 + 3) * 4 + 5)*6
We break the problem of parsing infix expressions into two stages. First, we convert from infix to a different representation called postfix. Then we parse the postfix expression, which is a somewhat easier problem than directly parsing infix. Converting from Infix to Postfix. Typically, we deal with expressions in infix notation
2 + 5
where the operators (e.g. +, *) are written between the operands (e.q, 2 and 5). Writing the operators after the operands give a postfix expression 2 and 5 are called operands, and the ‘+’ is the operator. The above arithmetic expression is called infix since the operator is in between operands. The expression
2 5 +
Writing the operators before the operands gives a prefix expression
+2 5
Suppose you want to compute the cost of your shopping trip. To do so, you add a list of numbers and multiply them by the local sales tax (7.25%):
70 + 150 * 1.0725
Depending on the calculator, the answer would be either 235.95 or 230.875. To avoid this confusion we shall use a postfix notation
70 150 + 1.0725 *
Postfix has the nice property that parentheses are unnecessary.
Now, we describe how to convert from infix to postfix.

Read in the tokens one at a time

If a token is an integer, write it into the output

If a token is an operator, push it to the stack, if the stack is empty. If the stack is not empty, you pop entries with higher or equal priority and only then you push that token to the stack

If a token is a left parentheses ‘(‘, push it to the stack

If a token is a right parentheses ‘)’, you pop entries until you meet ‘(‘

When you finish reading the string, you pop up all tokens which are left there
 Arithmetic precedence is in increasing order: ‘+’, ‘‘, ‘*’, ‘/’;
Example: Suppose we have an infix expression:2+(4+3*2+1)/3. We read the string by characters.
‘2’ – send to the output
‘+’ – push on the stack
‘(‘ – push on the stack
‘4’ – send to the output
‘+’ – push on the stack
‘3’ – send to the output
‘*’ – push on the stack
‘2’ – send to the output
Evaluating a Postfix Expression
We describe how to parse and evaluate a postfix expression.

We read the tokens in one at a time

If it is an integer, push it on the stack
 If it is a binary operator, pop the top two elements from the stack, apply the operator, and push the result back on the stack
Consider the following postfix expression
5 9 3 + 4 2 * * 7 + *
Here is a chain of operations
Note, that division is not a commutative operation, so 2/3 is not the same as 3/2.
Implementation
In the standard library of classes, the data type stack is an adapter class, meaning that
a stack is built on top of other data structures. The underlying structure for a stack could be an array, a vector, an ArrayList, a linked list, or any other collection. Regardless of the type of the underlying data structure, a Stack must implement the same functionality. This is achieved by providing a unique interface.
The following picture demonstrates the idea of implementation by composition.
Another implementation requirement (in addition to the above interface) is that all stack operations must run in constant time O(1). Constant time means that there is some constant k such that an operation takes k nanoseconds of computational time regardless of the stack size.
In an arraybased implementation, we maintain the following fields: an array A of default size (≥ 1), the variable top that refers to the top element in the stack and the capacity that refers to the array size. The variable top changes from 1 to capacity – 1. We say that a stack is empty when top = 1, and the stack is full when top = capacity1.
In a fixedsize stack abstraction, the capacity stays unchanged, therefore when top reaches capacity, the stack object throws an exception. In a dynamic stack abstraction when top reaches capacity, we double up the stack size.
Linked List base Implementation
Linked Listbased implementation provides the best (from the efficiency point of view) dynamic stack implementation.
Also see, Morris Traversal for Inorder.
You can also read Difference Between Array List and Linked List here.
Also read about  hash function in data structure