| CSC 161 | Grinnell College | Spring, 2015 |
| Imperative Problem Solving and Data Structures | ||
The following shows the output of stack-project.c for four implementations of stacks, as described in Project: Variations with Stacks
initialization of stack --- implementation 1
stack struct contains array of pointers of base addresses
program to follow status of string variables during processing
progress commentary a b c d e f g h
initialize a, b, c apple beans corn
pop to get d, e, f apple beans corn corn beans apple
change a, e fruit peas corn corn peas fruit
push new g, h fruit peas corn corn peas fruit beet olive
change g fruit peas corn corn peas fruit dill olive
initialization of stack --- implementation 2
stack struct contains array of strings
program to follow status of string variables during processing
progress commentary a b c d e f g h
initialize a, b, c apple beans corn
pop to get d, e, f apple beans corn corn beanscorn applebeanscorn
change a, e fruit beans corn corn peas applebeanscorn
push new g, h fruit beans corn corn peas applebeanscorn beet olive
change g fruit beans corn corn peas applebeanscorn dill
Olive
initialization of stack --- implementation 3
strings copied before being put on stack
program to follow status of string variables during processing
progress commentary a b c d e f g h
initialize a, b, c apple beans corn
pop to get d, e, f apple beans corn corn beans apple
change a, e fruit beans corn corn peas apple
push new g, h fruit beans corn corn peas apple beet olive
change g fruit beans corn corn peas apple dill olive
initialization of stack --- implementation 4
stack struct i array of strings, copying in, return address
program to follow status of string variables during processing
progress commentary a b c d e f g h
initialize a, b, c apple beans corn
pop to get d, e, f apple beans corn corn beanscorn applebeanscorn
change a, e fruit beans corn corn peas applepeas
push new g, h fruit beans corn corn olivecorn beet beet olive
change g fruit beans corn corn olivecorn beet dill olive