Stacks and queues with templates and expectation handling Flashcards
what is stack
Collection of objects that are inerted/ removed according last in first out principle
main stack operations
Push - inserts element on top
Pop- removes last element
getTop- return last inserted element
Size
Is empty
array based stack properties
Add elements from left to right
Remove elements from right to left
Variables keeps track of index of last item pushed
linked list stack Properties
Remove the size restrictions
Head points to nul
Push-isert head
Pop- remove head
qhat is queue ADT
-is a collection of objects inserted and removed according to the first in first out principle
- objects are inserted at the rear of the queue
-objects can only be removed from the front of the queue