Week 5

Post date: Feb 02, 2019 6:26:55 PM

Chapter 4 Stacks:

Queues, Priority Queues

Lab 5 – Queue

Objectives:

Learn How to Implement Queue using Doubly Linked List

Learn How to Use Queue

Examples:

1- Class ArrayQueue shows how queue may be implemented using array (as discussed in the lecture). Class TestArrayQueue shows how this class may be used to perform the following operations:

- Enqueue an element

- Dequeue an element and print it

- Get first element and print it

- Print all elements in the queue

- Clear the queue

- Quit

2- Class LLQueue shows how queue may be implemented using java.util.LinkedList (as discussed in the lecture). Class TestLLQueue shows how to use this class.

Tasks:

1. The given file DLL.java implements a generic linked list as we saw in Lab03.

(a). Use this class to implement a class, DLLQueue, that represents a queue for processing any types of values (generic queue).

(b) Write a test class, TestDoubleQueue, that uses DLLQueue to allow a user to perform the same operations as TestLLQueue but using Double data objects.

(c) Write a test class, TestStudentQueue, that allows a user to perform the same operations as in (b) above but using Student objects.

2. Similarly, the given file ArrayQueue.java implements an array of Objects.

(a). Use this class to implement a class, ArrayListQueue, that represents a queue for processing any types of values (generic queue).

(b) Write a test class, TestDoubleArrayListQueue, that uses ArrayListQueue .

(c) Write a test class, TestStudentArrayListQueue, that allows a user to perform the same operations as in (b) above but using Student objects.