






| |
Layout of the Stack Data Structure
Below is a screenshot of the Watson Data Structures Lab about stacks. As you can
see, the major sections of the lab are numbered and explained below the image.
- Watson Control
Bar - The common Watson control bar for all applications.
This bar contains all the functions to select an activity and get important
information about the lab.
- Data Set - Contains all the data or information which may be used within an activity.
- Stack - A sequence of items, all of the same type, that can only be accessed from one end.
- Top Pointer - A pointer to the current or top element on the stack.
- Temp Variable - A variable used to temporarily store a value from the data set.
- Pop Button - Removes the top item from the stack and return its value.
If the stack is empty, raise an "Stack Empty" exception.
- Push Button - Puts an item to the top of the stack.
All operations on a stack are relative to the top of the stack; no other items in the stack may be manipulated until they become the top item.
The animated figure below demonstrates how the top pointer works.
Stack Intro Activity
Below is a set of step-by-step instructions on how the example works.
- Click on the button labeled 'Activity'.
- Select the Stack Intro activity and click on the 'OK' button to begin the program.
- Click on the 'OK' after viewing the activity description for the stack intro exercise.
- Move the cursor to the 'Data Set' window over the button labeled '1st floor' and click. Then move
your cursor to the 'Stack' window and click on the 'Push' button.
- Repeat step 4 for floors 2 through 7.
- Move the cursor over to the button labeled 'Pop' and click on it.
- Repeat step 5 for the 6th floor.
- Press any key on the keyboard to answer the questionnaire at the top of the screen.
- Choose one of the three choices listed.
|