Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

18. Give the line numbers of the code presented in Figure 3.26 that perform the

ID: 670979 • Letter: 1

Question

18. Give the line numbers of the code presented in Figure 3.26 that perform the garbage collection for the structure Queue.

Here is editable Figure 3.26

public clas Queue
{private Listing [] data;
private int size;
private int numOfNodes;
private int front;
private int rear;
public Queue ()
{
size = 100;
numOfNodes = 0;
front = 0;
rear = 0;
data = new Listing [n];
}
public boolean enque(Listing newNode)
{
if(numOfNodes == size)
return false; //** overflow error **
else
{
numOfNodes = numOfNodes + 1;
data[rear] = newNode.deepCopy();
rear = (rear + 1) % size;
return true; //push operation succesful**
}
}
public Listing deque()
{
int frontLocation;
if(numOfNodes == 0)
return null; //**underflow error**
else
{
frontLocation = front;
front = (front + 1) % size;
numOfNodes = numOfNodes - 1;
return data[frontLocation];
}
}
public void showAll()
{
int i = front;
for(int c = 1; c <= numOfNodes; c++)
{
System.out.println(data[i].toString());
i = (i + 1) % size;
}
} // end of showAll method
} //end of class Queue

1 public class Queue 2. private Listing data; private int size; private int numOfNodes; private int front; private int rear public Queue () { size= 100; numofNodes0; front = 0; rear 0; data = new Listing[ 100]; 12 public Queue (int n) { size=n; 15 17 18 19 20 21 public boolean enque (Listing newNode) numOfNodes = 0; front 0; rear 0; data new Listing[n]; if (numof Nodessize) 23 return false overflow error else 25 26 27 28 29 numofNodes numof Nodes1; data [rear] = newNode.deepCopy(); rear (rear + 1) % size return true; I push operation successful 31. public Listing deque() 32. int frontLocation return null; underflow error else 35 36 37 frontLocation front; front (front + 1) % size; numOf Nodes numOf Nodes 1 ; return datalfrontLocation] 40 42. public void showA1l() 43.int front; for (int c 1 cnumOfNodes; c++) System.out.printin(datali).tostringO i=(i + 1) % size; 45 46 47 48. I end of showAll method 49. / end of class Queue

Explanation / Answer

No garbage collection is being performed in this code. Please give the full code, including the Listing class and main method!

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at drjack9650@gmail.com
Chat Now And Get Quote