Skip to main content

Exercises 29.7 Exercises

1.

Write the enqueue function for the Array Based Queue.
You do not need to worry about the queue being full, but you should correctly handle wrapping.

2.

Write the dequeue function for the Array Based Queue.

3.

Write the full function for the Array Based Queue.
You will need your enqueue and dequeue functions.

4.

Write the grow function for the Array Based Queue.
It should double the size of the underlying array and copy the existing elements to the new array in the correct order.
You will need your enqueue and dequeue functions.
Hint 1.
You will need to loop from start to end and may need to wrap around while looping.
Hint 2.
You will likely need/want a different counter for the location in the new array. The logic is easiest if you place the elements in the new array starting from 0. They will never need to wrap in the new array.
You have attempted of activities on this page.