Queues Flashcards
What does the enqueue(Object) method do?
Inserts an element at the end of the queue.
What does the object dequeue( ) method do?
Removes and returns the element at the
front of the queue.
What are the main queue operations?
enqueue( Object ) and Object dequeue( )
What does the Object first ( ) method do?
Returns the element at the front without
removing it.
What does the integer size( ) method do?
Returns the number of elements stored in the queue.
What does the boolean isEmpty( ) method do?
Indicates whether no elements are
stored in the queue.
What are the auxiliary methods of a queue?
first( ), size( ), isEmpty( )
How do you find the back index of a queue implemented by an array with a size less than array.length?
When the queue has less than array.length elements you can find the back index back = (front + size) % array.length.
What’s the pseudocode for enqueue ( catObject )?
back = (front + size) % array.length
array[back] = catObject
size++
Whats the pseudocode for dequeue( )?
item = array[front]
front = (front + 1) % array.length
size–
return item