Lecture 28: Going over quiz; intro stacks + queues; intro Project 4
Lecture video kept cutting out so not bothering to post to YouTube…see three short videos on Panopto.
Textbook chapters
6.1-6.2
Abstract data type (ADT)
Abstraction of a data structure.
Specifies:
- data stored
- operations on the data
- error conditions associated with operations
Stack
Has operations:
push(object)
: inserts an element at toppop()
: removes and returns top elementtop()
(orpeek()
): returns element at top of stack without removingsize()
: returns the number of elements storedisEmpty()
: returns whether the stack is empty
Java has an implementation: java.util.Stack
We can implement with an internal array or an internal linked list. See Project 4.
Queue
Has operations:
enqueue(object)
: inserts an element at enddequeue()
: removes and returns top elementfirst()
: returns element at front of queue without removingsize()
: returns the number of elements storedisEmpty()
: returns whether the queue is empty
Java has an implementation: java.util.Queue
We can implement with an internal linked list (see Project 4) or an internal array (see book).