write my assignment 26179

<> <>{ DEFAULT_CAPACITY = ; front, rear, count; T[] queue; {front = rear = count = ;queue = (T[]) ( Object[DEFAULT_CAPACITY]); } initialCapacity) {front = rear = count = ;queue = ( (T[])( Object[initialCapacity]) ); } { (size() == queue.length) expandCapacity();queue[rear] = element;rear = (rear+) % queue.length;count++; } T EmptyCollectionException { (isEmpty()) EmptyCollectionException ();T result = queue[front];queue[front] = ;front = (front+) % queue.length;count–; result; } T EmptyCollectionException { } { } { } String { } {T[] larger = (T[])( Object[queue.length *]);( scan=; scan < count; scan++){larger[scan] = queue[front];front=(front+) % queue.length;}front = ;rear = count;queue = larger; }} <>{ ; T ; T ; ; ; { { ( + collection + ); }}Download Circula rArrayflueue. java . (luaueAEIT. java and Emptytouect iunEXCeptien . java from the sample oode page and fill inthe missing code In the methods. The oodefor the helper method expandCapacity is given: note that it is different from theexpandtapac ity of the regular array implementations that we have seen for the Stack ADT and Queue ADT.- first Is slmilarto dequeee . but doesn’t remove the element- isEmpty and size are trivial- for tnSt ring . setting up the string Is similar in concept to the toSt ring method in A rra yStac k.j ava . which was similar to thefollowing: public String toString(}{String result = &quot;&quot;,’for [int i=3.- i c top; in]result 2 result + stackli] .toStringlJ + &quot;n&quot;;return result: } – Of course the attributes are no longer called stack and top. so you need to change those. But. more importantly. you will not be startingthe array Index at u. – The oounter for the loop can still go from D to count , since yw will still go through the for loop as many times asthere are items in thequeue. But the array index will need to be a different variable, that starts at the value in the attribute f rant . – You will need to increment the array index in the body of the for loop. taking Into aocount that it may need to wrap around to the beginning ofthe array again. It is the same idea as how rear Is Incremented in the anqueue method. and how front is incrementedin the provided expandCepacity method.
"Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!"

Comments are closed.

Hi there! Click one of our representatives below and we will get back to you as soon as possible.

Chat with us on WhatsApp