Question: R-6.7: Suppose an initially empty queue Q has performed a total of 32 enqueue operations, 10 first operations, and 15 dequeue operations, 5 of which
R-6.7: Suppose an initially empty queue Q has performed a total of 32 enqueue operations, 10 first operations, and 15 dequeue operations, 5 of which returned null to
indicate an empty queue. What is the current size of Q? Size of Queue is 22
I need to answer R-6.8
R-6.8: Had the queue of the previous problem been an instance of the ArrayQueue class, from Code Fragment 6.10, with capacity 30 never exceeded, what would be the final value of the instance variable f?
Code Fragment 6.10:

6 8 9 1 /** Implementation of the queue ADT using a fixed-length array. */ 2 public class ArrayQueue implements Queue { 3 // instance variables 4 private E[ ] data; // generic array used for storage 5 private int f = 0; // index of the front element private int sz = 0; // current number of elements 7 // constructors public ArrayQueue() {this(CAPACITY);} // constructs queue with default capacity 10 public ArrayQueueint capacity) { // constructs queue with given capacity 11 data = (E[ 1) new Object[capacity]; // safe cast; compiler may give warning 12 } 13 14 // methods 15 /** Returns the number of elements in the queue. */ 16 public int size() { return sz; } 17 18 /** Tests whether the queue is empty. */ 19 public boolean isEmpty() { return (sz 0); } 20 21 /** Inserts an element at the rear of the queue. */ 22 public void enqueue(E e) throws IllegalStateException { 23 if (sz data.length) throw new IllegalStateException("Queue is full"); 24 int avail - (f + sz) % data.length; // use modular arithmetic 25 data[avail] = e; 26 sz++; 27 } 28 29 /** Returns, but does not remove, the first element of the queue (null if empty). */ 30 public E first() { 31 if (isEmpty()) return null; 32 return data[f]; 33 } 34 35 /** Removes and returns the first element of the queue (null if empty). */ 36 public E dequeue() { 37 if (isEmpty()) return null; 38 E answer = data[f]; 39 data[f] = null; // dereference to help garbage collection 40 f= (f + 1) % data.length; 41 SZ--; 42 return answer; 43 } Code Fragment 6.10: Array-based implementation of a queue. =