Professional Documents
Culture Documents
Pop
public ArrayStack(){
this(CAPACITY);
}
1.Get next character a or b from input string and push onto the stack; repeat
until the symbol c is encountered.
2.Get next character a or b from input string, pop stack and compare. If the two
symbols match, continue; otherwise, stop – the string is not in L.
Additional
states where the input string is not in L:
1.The end of the string is reached but no c is encountered.
2.The end of the string is reached but the stack is not empty.
3.The stack is empty but the end of the string is not yet reached.
Some properties:
degree of an operator - number of operands it has
the rank of an operand is 1, the rank of an operator is 1 minus its degree,
the rank of an arbitrary sequence of operands and operators is the sum
of the ranks of the individual operands and operators
if z = x | y is a string, then x is the head of z. x is a proper head if y is
not the null string
Knuth's implementation: