- #1
evinda
Gold Member
MHB
- 3,836
- 0
Hello! (Smile)
I am looking at the algorithms [m]Pop[/m] and [m]Push[/m] of a stack:
Why doesn't [m]S=P[/m] work in C?
How can we find how much memory the algorithm [m]Pop[/m] needs? (Thinking)
I am looking at the algorithms [m]Pop[/m] and [m]Push[/m] of a stack:
Code:
void Push(info x, pointer S)
pointer P; /* temporary pointer */
P=NewCell(NODE); /* malloc() */
P->data=x;
P->next = S;
S=P; /* This wouldn't give the right result in C*/
Why doesn't [m]S=P[/m] work in C?
Code:
info Pop(pointer S)
info x;
if (IsEmptyStack(S)) then error;
else
x=Top(S);
S=S->next;
return x;
How can we find how much memory the algorithm [m]Pop[/m] needs? (Thinking)