Java Reference
In-Depth Information
This implementation supplies a bounded queueȌit can eventually fill up.
See the next exercise on how to remove that limitation.
694
695
Figure 14
Adding and Removing Queue Elements
Figure 15
A Queue That Wraps Around the End of the Array
΢΢΢Exercise P15.13. The queue in Exercise P15.12 can fill up if more
elements are added than the array can hold. Improve the implementation
as follows. When the array fills up, allocate a larger array, copy the
values to the larger array, and assign it to the elements instance
variable. Hint: You can't just copy the elements into the same position of
the new array. Move the head element to position 0 instead.
΢΢Exercise P15.14. Modify the insertion sort algorithm of Advanced Topic
14.1 to sort a linked list.
Search WWH ::




Custom Search