EXERCISE 3 (Done)
EXERCISE 3 (Done)
1. A stack is a data structure that works on the principle of Last in First out (LIFO). List and
draw 3 examples implementation of stack in real life situation.
2. List and describe 5 operations in a stack:
ii. push(char)
Insert item onto stack
iii. pop() Delete item
[2] 45
[1] 68
[0] 99
Figure 1
4. Convert the stack data structure at Figure 1 to linked list. Then, show top of stack
5. Differentiate implementation of stack using linked list and array
Top of
stack
Size
Element
Insertion
Test full
stack
6. Draw a suitable stack diagram for each statement below. Given that the Stack of T
contents of four (4) elements.
Procedure:
Step 4: Draw the final picture after all of the operations has been performed.
7. Imagine we have one empty stack of integers, s1. Draw a picture of each stack after the
following operations being performed:
pushStack (t1, 2)
pushStack (t1, 6)
pushStack (t1, 8)
pushStack (t1, 9)
pushStack (t1, 10)
pushStack (t1, 12) i.
popStack (t1, x)
popStack (t1, x)
pushStack (t2, 15)
pushStack (t2, 5)
pushStack (t2, 1)
popStack (t2, x)