CPSC 170 Prelab 10: Queues

  1. Under what circumstance are front and back equal (the references, not the values stored there) in each queue implementation:
    1. Linked
    2. Fixed array
    3. Circular array

  2. Give the complexity of each queue operation for each implementation:
      Linked Fixed array Circular array
    enqueue      
    dequeue      
    isEmpty      

  3. Consider the values below, which represent a circular array implementation of a queue.
            front: 4
            back:  2
                       -------------------
            elements: | A | B | C | D | E |
                       -------------------
                        0   1   2   3   4
    
    1. List the elements in the queue, from front to back.


    2. Show the values of front, back, and elements after the following operations. Show all of the values in the array, not just the ones in the queue.
      dequeue();
      dequeue();
      q.enqueue("F");
      q.enqueue("G")
      q.enqueue("H");
      dequeue();
      dequeue();
      q.enqueue("I");
      




    3. What is the relationship between front and back when the queue is empty?




    4. What is the relationship between front and back when the queue is full (that is, when the array would have to be expanded to add another element)?