- #1
evinda
Gold Member
MHB
- 3,836
- 0
Hello! (Smile)
A static stack is implemented with the use of a one-dimensional array $A$.
Suppose that we have a pointer $S$ to a struct that has two fields, the array $A$ and the integer Length, and represents a stack.
According to my notes, the operation [m] Push [/m] for a static stack is the following:
But don't we have to check also if [m]S->Length+1==N[/m] ? Or am I wrong?
A static stack is implemented with the use of a one-dimensional array $A$.
Suppose that we have a pointer $S$ to a struct that has two fields, the array $A$ and the integer Length, and represents a stack.
According to my notes, the operation [m] Push [/m] for a static stack is the following:
Code:
void Push(Pointer S, Type x)
if (S->Length==N) then error;
else {
S->Length=S->Length+1;
(S->A)[S->Length-1]=x;
}