Queues Exercises

  1. List the basic operations of a queue (and explain each one to the members at your table)
  2. Identify the Big-O for each of the basic operations
  3. Identify multiple examples of queues in everyday life
  4. Compare and contrast lists and queues (for example, which methods need to be changed?)
  5. Compare and contrast stacks and queues (for example, which methods need to be changed?)
  6. Talk with the members of your table and determine in the textbook's AQueue class, which end do we remove values from?
  7. Talk with the members of your table and determine in the textbook's AQueue class, does the instance variable front indicate:
    1. where the front item is located
    2. where the front item will be located
    3. where the front item was located
    What does rear indicate?
    Specifically, given the following contents of a queue, what will be the the values of front and rear:
     Index   0   1   2   3   4   5   6   7   8   9   10 
     Y   Z      D   E   F   G   H   I   X 
  8. Write the contents of an array queue after each of the following operations (be sure to clearly indicate the front and rear elements in the queue):
    • enqueue( A )
    • enqueue( B )
    • dequeue( )
    • enqueue( C )
    • dequeue( )
    • dequeue( )

    Repeat with a linked queue.

  9. Write the contents of an array queue after each of the following operations (be sure to clearly indicate the front and rear elements in the queue):
    • enqueue( 's' )
    • enqueue( 't' )
    • enqueue( 'r' )
    • enqueue( 'e' )
    • enqueue( 's' )
    • enqueue( 's' )
    • enqueue( 'e' )
    • enqueue( 'd' )
    • dequeue( )
    • dequeue( )
    • dequeue( )
    • dequeue( )
    • dequeue( )
    • dequeue( )
    • dequeue( )
    • dequeue( )

    Repeat with a linked queue.

    Write the representation of the array-based queue (assuming it has a requested size of 10) and the above operations are performed and then the following operations are performed:

    • enqueue( '!' )
    • enqueue( '?' )
    • enqueue( '@' )
    • dequeue( )
    • dequeue( )
    • dequeue( )

  10. Linked queue demo (with adapted code from the textbook).

Last Modified: