Data Structures and Algorithms Mid-Term Study Flashcards
The Queue ADT
-stores arbitrary objects- insertions and deletions follow the first-in, first-out scheme-insertions at the rear,removals at the front
enqueue()
inserts an element at the end of the queue
dequeue()
removes and returns the element at the front of the queue
object first() (Queue)
returns the element at the front without removing it
integer size() (Queue)
returns the number of elements stored
boolean isEmpty() (Queue)
indicates whether no elements are stored
Queue boundary cases
Attempting the execution of deqeueue() or first() on an empty queue returns null
Direct Applications for a Queue
- Waiting lists, bureaucracy- Access to shared resources- Multiprogramming
Indirect Applications for a Queue
- Auxiliary data structure for algoritms- Component of other data structures
Queue is limited to the __________ of the array.
size
Queue Performance runs in _________.
O(1)
enqueue() corresponds to what java.util.Queue?
add(e)offer(e)
dequeue() corresponds to what java.util.Queue?
remove()poll()
In a queue, first() corresponds to what java.util.Queue?
element()peek()
In a queue, size() corresponds to what java.util.Queue?
size()