Data Structures - Array Based Queue

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

The left justified strategy that has worked for the Bag, Set, List and Stack collections ________ _____ works well for the Queue collection

The left justified strategy that has worked for the Bag, Set, List and Stack collections no longer works well for the Queue collection

A circular queue or circular array strategy keeps the elements of the array ______, but allows them to float down toward the _____ and then wrap around once they hit the ______

A circular queue or circular array strategy keeps the elements of the array strategy, but allows them to float down towards the right and then wrap around once they hit the end

All three methods of the Array Queue have a time complexity of ______. The enqueue method is ________

All three methods of the Array Queue have a time complexity of O(1). The enqueue method is amortized

By anchoring one end of the queue at index 0, ________ would be required in either enqueue or dequeue

By anchoring one end of the queue at index 0, shifting would be required in either enqueue or dequeue

By anchoring one end of the queue at index 0, the time complexity if enqueue an dequeue would be ________ or ________ depending on which does linear search

By anchoring one end of the queue at index 0, the time complexity if enqueue an dequeue would be O(1) or O(N) depending on which does linear search

Front gets _______ each time an element is removed and rear changes to the ______ element added

Front gets incremented each time an element is removed and rear changes to the last element added

For enqueue method, we set element[rear] equal to ______. We then set rear equal to _______ + 1 and then we use the remainder operator to divide it by _____________. We then increment ________

For enqueue method, we set element[rear] equal to element. We then set rear equal to (rear + 1) and then we use the remainder operator to divide it by elements.length. We then increment size.

For the dequeue method, we check if the queue is ____. If it is we return _______. We then set T result equal to ________. We set elements[front] equal to _______. Then we set front equal to _______ + 1. We divide this using the remainder operator by _______. We then decrement _______ and return ________

For the dequeue method, we check if the queue is empty. If it is we return null. We then set T result equal to elements[front]. We set elements[front] equal to null. Then we set front equal to (front + 1). We divide this using the remainder operator by elements.length. We then decrement size and return result.

For the enqueue method we are always concerned with ________

For the enqueue method we are always concerned with capacity

For the enqueue method, if the size of the queue is the same as the length of the array, we need to ________

For the enqueue method, if the size of the queue is the same as the length of the array, we need to resize

The first method checks if the queue is _____ and returns ______ if it is. Otherwise it returns ________

The first method checks if the queue is empty and returns null if it is. Otherwise it returns elements[front]

The resize method will first create a new array. Then it will set i to _______ and j to ________. We then loop using k and ______. We set the newArray[i] equal to ________. We then increment i and set j equal to ________ + 1. We then use the % operator and divide it by ________. We set elements equal to ________. Then we set front equal to ________ and rear equal to________.

The resize method will first create a new array. Then it will set i equal to 0 and j equal to front. We then loop using k and size. We then increment i and set j equal to (j + 1). We then use the % operator and divide it by elements.length. We set elements equal to newArray. Then we set front equal to 0 and rear equal to size.

We need to use a ____ ____ strategy to make both enqueue and dequeue O(1)

We need to use a circular array strategy to make both enqueue and dequeue O(1)


Kaugnay na mga set ng pag-aaral

Geology Lab: Common Minerals and Their Uses

View Set

REA4360 Reading Across the Curriculum

View Set

Psychology Chapter 8, Psych. Ch. 8, Chapter 8, Chapter 7: Memory, Psyc Chapter 8, Psychology: Chapter 8

View Set

HESI with Rationale 12 366 rn exit Hesi

View Set