Queues Flashcards

1
Q

What does the enqueue(Object) method do?

A

Inserts an element at the end of the queue.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does the object dequeue( ) method do?

A

Removes and returns the element at the

front of the queue.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the main queue operations?

A

enqueue( Object ) and Object dequeue( )

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What does the Object first ( ) method do?

A

Returns the element at the front without

removing it.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What does the integer size( ) method do?

A

Returns the number of elements stored in the queue.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What does the boolean isEmpty( ) method do?

A

Indicates whether no elements are

stored in the queue.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are the auxiliary methods of a queue?

A

first( ), size( ), isEmpty( )

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How do you find the back index of a queue implemented by an array with a size less than array.length?

A

When the queue has less than array.length elements you can find the back index back = (front + size) % array.length.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What’s the pseudocode for enqueue ( catObject )?

A

back = (front + size) % array.length
array[back] = catObject
size++

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Whats the pseudocode for dequeue( )?

A

item = array[front]
front = (front + 1) % array.length
size–
return item

How well did you know this?
1
Not at all
2
3
4
5
Perfectly