public class PQueuecE extends Comparable > { private E [] elements: private int
ID: 3860383 • Letter: P
Question
public class PQueuecE extends Comparable > { private E [] elements: private int size: private int head: private int tail: private int count;/constructor implemaentation not printed /isFull () and isEmpty () not printed ublic void enqueue (E item) { if (isFull ()) { return: } count + +: elements [tail] = item: tail = (tail + 1) % size: ublic E dequeue () { if (isEmpty ()) return null: int ct = count - 1: E cur = elements [head]: int index = theta: for (i = 1: ct - - > theta: i + +) { if cur. compareTo (elements [(head + i) % size]: index = i: } } return removed ((head + index) % size): public E removed (int index) { E item elements [index] if (index = tail) { int i: for (i = index: (i % size) = tail: 1 +) { int j = i % size: elements [j] = elements [(j + 1) % size]: } } tail = (tail - 1) % size: count - -: return item: } } public class Test { public static void main (string [] argv) { pQueue queue = new pQueue (): for (int i = 1: iExplanation / Answer
This program will not give any output... rather it will give syntax and runtime errors...
reasons:
private variables of class PQueue are not initialized by constructor.
and generic array declaration is not as per the syntax..
some methods are missing..
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.