Algorithm
What needs to be done for change #1:
- to eliminate the first cell, call
return_memory
return_memory
needs to be given a pointer.
- where do we find this pointer? It is the TOP pointer in S.
Pseudo code for change #1:
- Step 1a: Get_Rid_of_this = S's TOP pointer
- Step 1b:
return_memory(
Get_Rid_of_This)
What needs to be done for change #2:
- operation to change S's TOP pointer: assignment
- information needed: pointer to the cell that TOP should point
to.
- where to find this pointer? It is the next pointer of
the cell deleted by change #1.
Pseudo code for change #2:
- Step 2a: Top_Cell = dereference S's TOP pointer
- Step 2b: S's TOP pointer = Top_Cell's next pointer.