Lecture 1 - ADTs Flashcards
What methodology does a stack follow?
Last In First Out
What are the basic operations of a stack?
- create
- isEmpty
- push
- pop
How can a stack be implemented?
- array
- linked list
What is the time complexity of stack operations when it is implemented with an array ?
O(1)
What is the time complexity of stack operations when it is implemented with a linked list ?
O(1)
What methodology does a queue follow?
First In First Out
What are the basic operations of a queue?
- create
- isEmpty
- insert
- delete
What is the time complexity of queue operations when it is implemented with an array ?
O(1) when using a circular queue
What is the time complexity of queue operations when it is implemented with a linked list ?
O(1) when we have a head and tail
What is a priority queue compared to a queue?
The order of removal depends on priority rather than time of addition.
What are the operations on a priority queue?
same as a queue
How can a priority queue be implemented?
- linked list (ordered or unordered)
- heap
What is the time complexity for create and isEmpty for all implementations?
O(1)
What is the time complexity of insert and delete for an LL implementation?
Ordered: O(n) for delete and O(1) for insert
Unordered : O(1) for insert O(n) for delete
What is the time complexity of insert and delete for a heap implementation?
O(logn)