Stacks and Queues
- What is a stack?
- last in first out LIFO?
- A time ordered data structure?
- What are the basic stack operations and performance expectation of those operations?
-
Push(item)
-
Pop()
-
itemT Top()
-
int Size()
- And occasionally
bool IsEmpty()
bool IsFull()
For stacks
- It is expected that all of these operations are constant time.
- Can this be implemented in a linked list?
- Can this be implemented in an array?
- Would a dynamic array help?
- Which would you choose and why?
What are is a queue?
What are the basic operations on a queue?
-
Enqueue(item)
-
Dequeue()
-
itemT Front()
-
int Size()
Constant time performance for this as well.
Can we implement a queue?